in reply to Glob seekpointer
According to perlop, this is exactly what it does - it will keep going until the end before starting over. Thus, you want something like:
But I still don't like it. Use glob rather than the <> operator.$rc = 1; while (defined($nextfile = <$dirName/*cm*.4gl>)) { if ($rc) { $rc = system("grep $field $nextfile 1> /dev/null"); if (!$rc) { print FOUND "$field $nextfile\n"; } } }
I'd also recommend a few minor other changes:for my $nextfile (glob File::Spec->catfile($dirName, '*cm*.4gl')) { $rc = system("grep $field $nextfile 1> /dev/null"); if (!$rc) { print FOUND "$field $nextfile\n"; last; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Glob seekpointer
by Shylock (Acolyte) on Feb 25, 2005 at 06:05 UTC |