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:

$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"; } } }
But I still don't like it. Use glob rather than the <> operator.
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; } }
I'd also recommend a few minor other changes: Hope this helps.

Replies are listed 'Best First'.
Re^2: Glob seekpointer
by Shylock (Acolyte) on Feb 25, 2005 at 06:05 UTC
    Thanks, that did the trick.