in reply to Re: Re: Re: Passing filehandle to sub
in thread Passing filehandle to sub

One more reason TO use the variable method:

Better error messages, as you can get the filename in messages using the following:

my $f = "/etc/hosts"; open($f, $f); readit($f); sub readit { my $h = shift; print while(<$h>); warn; }
The result:
last line of output is:
Warning: something's wrong at ./t25.pl line 11, </etc/hosts> line 12.


--Bob Niederman, http://bob-n.com