in reply to print htmlcode issue

You need to obtain a filehandle for wherever you wish to direct the print:

open FH, "> somefilename" or die $!; print FH <<HTMLCODE; ZXCZXC zxcZXCzx zxczxczxc zxczxczxzx HTMLCODE close FH or die $!;
The handle may also be from pipe or socket.

Update: To get STDOUT assigned somewhere else, just use that as the filehandle:

open STDOUT, "> thefilepath" or die $!;
Then the default handle for print is the file.

Update: Juerd, yes, buffered writes will fail on close if the device is full or quota exceeded.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re: Re: print htmlcode issue
by Juerd (Abbot) on Apr 19, 2002 at 10:52 UTC

    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.
    

      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.