in reply to Re: print htmlcode issue
in thread print htmlcode issue

close FH or die $!;

Does close ever fail?

To me, it seems testing the print makes more sense:

print FH $foo or die $!;
Which can come in handy, because filehandles are not protected by strict.

- Yes, I reinvent wheels.
- Spam: Visit eurotraQ.

Replies are listed 'Best First'.
Re: Re: Re: print htmlcode issue
by mce (Curate) on Apr 19, 2002 at 12:25 UTC
    Yes,

    they can be in 5.6.1.

    use strict; my $fh; open ( $fh, "> /tmp/out") or die $!; print $fh "hallo"; close($fh); exit 0;
    Or by using the IO modules.

    Which has the advantage of autoclosing when leaving the block.
    ---------------------------
    Dr. Mark Ceulemans
    Senior Consultant
    IT Masters, Belgium

      my $fh;

      That is a lexical, not a file handle. It can contain a reference to a glob, and can _act_ like a filehandle, but it really is not. It is a real scalar, and open doesn't change that, it only assigns a reference to it.

      - Yes, I reinvent wheels.
      - Spam: Visit eurotraQ.