[Israel.pm] Array of file handles
Offer Kaye
offer.kaye at gmail.com
Mon Dec 13 06:43:09 PST 2004
On Mon, 13 Dec 2004 16:16:08 +0200, Shlomi Fish wrote:
>
> The problem is in this line. You need to write it as:
>
> print {$fharray[$h]} "file $h\n";
>
> I guess Perl frowns upon the print statement's filehandle being anything other
> than a simple variable if the braces are to be omitted.
>
No need to guess - this is writen explicitly in "perldoc -f print":
<blockquote>
FILEHANDLE may be a scalar variable name, in which case
the variable contains the name of or a reference to the file-
handle, thus introducing one level of indirection.
...
Note that if you're storing FILEHANDLES in an array or other
expression, you will have to use a block returning its value
instead:
print { $files[$i] } "stuff\n";
</blockquote>
Regards,
--
Offer Kaye
More information about the Perl
mailing list