use strict; my $mydir = "/path/paths"; my $bool = 0; opendir(DIR, $mydir) || die "Can not open $mydir: $!\n"; while (my $file = readdir(DIR)) { if($file =~ /^myname\.doc$/i) { $bool = 1; } } closedir(DIR); if($bool) { print "$file"; } #### Global symbol "$file" requires explicit package name at C:\Perl\bin\scrp.pl line 22. Execution of C:\Perl\bin\scrp.pl aborted due to compilation errors.