slurp - line numbering
[email protected] (allan) Sun, 14 Oct 2001 13:00:15 +0200
| Newsgroups | perl.macperl.anyperl |
|---|---|
| Message-ID | <[email protected]> |
is it somehow possible - while slurping a file - to still keep track of
the line numbers?
something like:
#!/usr/bin/perl -w
my $file = "1.txt";
# 11 - line number 1
# 22 - line number 2
# 55 - line number 3
# 77 - line number 4
open FILE, $file or die $!;
local $/;
$txt = <FILE>;
if ($txt =~ /55$/m) {
print $.;
# should print 3
}
thank allan