in reply to Passing value outside of loop

That's a lot of code just to see if there's a file $file in $dir. Use Perl's file tests:

my $dir = "/path/paths"; my $file = "myname.doc"; print "Found '$dir/$file'.\n" if -f "$dir/$file";

— Arien