if(-e $file){ print"File exists\n"; } ## And to test if its a directory... if(-d $file){ print"Its also a directory!\n"; }