# odd way to count lines of a file :-) use strict; use warnings; use IO::Handle; my $fh = IO::Handle->new; #good # $fh = do {local *FH}; #bad open ($fh, './test') or die("open failed: $!"); 1 while <$fh>; print "line: " . $fh->input_line_number(); __END__
$. has its drawbacks - it contains the line number of last filehandle accessed. So there's no safe evaluation at a distance.
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
In reply to Re: Last Line Read? (Any way to use IO::Handle methods on a "First-Class" Filehandle?)
by shmem
in thread Last Line Read? (Any way to use IO::Handle methods on a "First-Class" Filehandle?)
by blahblahblah
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |