On 22 Oct 2007 21:16:21 +0200, Shmuel Fomberg wrote:
>
> What I meant to write is that this code works:
> ----------
> use strict;
> use warnings;
> open my $fh, ">", "foofile.txt";
> my %hh = (handle => $fh);
> my $f2 = $hh{handle};
> print $f2 "something";
> -----------
>
> while this code does not:
> ----------
> use strict;
> use warnings;
> open my $fh, ">", "foofile.txt";
> my %hh = (handle => $fh);
> print $hh{handle} "something";
> -----------
>
> why?
This is the way perl parses FILEHANDLE syntax. Read "perldoc -f print"
for the explanation. The correct syntax is:
print { $hh{handle} } "something";
Or you may write it this way:
use IO::Handle;
$hh{handle}->print("something");
Rehards,
Mikhael.
--
perl -e 'print+chr(64+hex)for+split//,d9b815c07f9b8d1e'
_______________________________________________
Perl mailing list
[email protected]
http://perl.org.il/mailman/listinfo/perl