BEGIN { $0 =~ '(.*[\\\/])\w+\.\w+$'; $curr_dir = $1 || "./"; } open (FILE, "<${curr_dir}info.txt") || print "There is no INFO file here $0"; while ( my $line = ) { ...code here... } #It doesn't work...