I'm sorry, but I'm confused with your statement.
$ perl -MIO::Handle -le 'open my $fh, "<", shift or die $!; print $fh-
+>input_line_number while <$fh>' a_file_name
1
2
3
4
.
.
.
$ perl -MIO::Handle -le 'open my $fh, "<", shift or die $!; print (\$f
+h)->input_line_number while <$fh>' a_filename
REF(0x99d7cdc)
Can't call method "input_line_number" without a package or object refe
+rence at -e line 1, <$fh> line 1.
# $fh = do {local *FH}; #bad
$ perl -MIO::Handle -le 'my $fh = do {local *FH}; open $fh, "<", shift
+ or die $!; print (\$fh)->input_line_number while <$fh>' a_file_name
GLOB(0x846ccdc)
Can't call method "input_line_number" without a package or object refe
+rence at -e line 1, <FH> line 1.
Update: Added example code with "#bad" mark
Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!
|