in reply to Finding names in files
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; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Finding names in files
by gzayzay (Sexton) on Mar 29, 2006 at 18:23 UTC | |
by SamCG (Hermit) on Mar 29, 2006 at 18:44 UTC |