Perl keeps track of the current line number for you in the $. variable, so no need to count them your self.
Here's an implementation you can learn from (hopefully :-):
for my $file (@files) { my $has_dave; open my $fh, "<", $file or warn("Can't open $file - $!\n"), next; while (<$fh>) { last if $. > 20; $has_dave = 1 if /dave/i; } print "$file\n" unless $has_dave; }
In reply to Re: Finding names in files
by duff
in thread Finding names in files
by gzayzay
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |