Thanks for the suggestion, though I solved my actual problem per the response below (localizing $. wherever my module performed a seek() or used <>).
Instead of using IO::File as you propose, since open()'ed files are automatically IO::Handles, you can just "use IO::Handle;" to provide the input_line_number method (note the continue):
use strict; use warnings; use IO::Handle; while (<>) { my $lineno = ARGV->input_line_number; # print a status message every 100 lines warn "Processing $ARGV line $lineno\n" unless $lineno % 100; # do some processing stuff } continue { close ARGV if ARGV->eof; # else input_line_number won't reset per- +file }
(Update:) s/eof/ARGV->eof/ in the code example. (else a poorly written function, like my original seeky() would let the eof refer to the wrong file)
In reply to Re: Localization gotcha?
by benizi
in thread Localization gotcha?
by benizi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |