No such thing as a small change | |
PerlMonks |
Last Line Read? (Any way to use IO::Handle methods on a "First-Class" Filehandle?)by blahblahblah (Priest) |
on Jun 07, 2007 at 20:51 UTC ( [id://619901]=perlquestion: print w/replies, xml ) | Need Help?? |
blahblahblah has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I'm using someone else's code which opens a file for reading like so: I'd never seen that trick before. I found an explanation here: http://perl.plover.com/local.html#3_The_First_Class_Filehandle_Tr. I want to be able to report the last line number read. I could use $., but I thought IO::Handle's input_line_number method would be better (so I don't have to worry about whether this filehandle was the last one accessed). However, IO::Handle seems not to like the "do {local *FH};" trick. Here's a small example: I have two easy workarounds -- use $. carefully, or modify the original code -- but I was wondering if there's a cleaner way of getting the line number?
Thanks,
Back to
Seekers of Perl Wisdom
|
|