DavidFerrington has asked for the wisdom of the Perl Monks concerning the following question:
our %hash;
...
open_file();
...
write_to_file();
...
sub open_file {
open $hash{fh}, '<', 'myfile';
}
sub write_to_file {
print $hash{fh} 'some line of data\n";
}
however, if I change the write_to_file sub to be
sub write_to_file {
my $fh = $hash{fh};
print $fh 'some line of data\n";
}
that works, but I'd far rather do it the 'proper' way
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: using a filehandle stored in a hash
by FunkyMonk (Bishop) on Mar 28, 2010 at 11:08 UTC | |
by DavidFerrington (Acolyte) on Mar 28, 2010 at 11:18 UTC | |
|
Re: using a filehandle stored in a hash
by toolic (Bishop) on Mar 28, 2010 at 12:52 UTC |