[ABE.pm] Text::Template Q
Ricardo SIGNES
rjbs-perl-abe at lists.manxome.org
Wed Jul 26 11:04:48 PDT 2006
* "Faber J. Fedor" <faber at linuxnj.com> [2006-07-26T13:26:47]
> I now want to redirect the output to a file, so I thought simply
> doing this would work:
>
> open(OUTFILE, "> $myfile");
> my $report_destination = \*OUTFILE;
> printHeader();
You are using antique file handles. The all-caps, all-global filehandles will
come back to haunt you some day.
Instead, write this:
open my $report_dest, '>', $myfile;
printHeader;
Also, you should always check that the open succeeded.
open my $report_dest, '>', $myfile or die "failed to open $myfile: $!";
printHeader;
> Is there some magic about filehandles or scoping that I don't know about?
I'm not sure how Text::Template wants to receive its fh references. They're a
little weird, in general.
--
rjbs
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mail.pm.org/pipermail/abe-pm/attachments/20060726/6235ca39/attachment.bin
More information about the ABE-pm
mailing list