in reply to Search Directory

Tested & working

#!/Perl/bin/perl use strict; use warnings; my $dir = 'c:/'; my $file = 'autoexec.bat'; opendir(DIR,$dir); print "found" if grep /$file/,readdir(DIR) ; closedir(DIR);
so you can adapt that line to last if grep /$file/,readdir(DIR) ; to make your loop exit early

Replies are listed 'Best First'.
Re^2: Search Directory
by Anonymous Monk on Feb 01, 2005 at 19:54 UTC
    Hi,
    Getting this back:

    Software error: Can't "last" outside a loop block

    Anyone knows why?

      yes, its a very desriptive error. It means you tried to cut and paste the last statement i provided into your program and didn't put that statement inside a loop construct.. so perl says "Last?!? ... last what?"