#!/usr/bin/perl -l use File::Spec; my $file = "$mall_path/keywords/$filename"; print "Checking " . File::Spec->rel2abs($file); if (-e $file) { #file exists - set variable and other things }