problem in checking file exists or not.plz help me

bhas85

Junior Member
Jun 26, 2012
2
0
0
Hi All,

I had a problem in checking file exists or not.I need to check the files in list.txt and the same file is there in files directory or not.the if statment is not working.please suggest me.

!/usr/bin/perl
$PATH1='/home/n1013141/vijay/list.txt'
$PATH2='/home/n1013141/vijay/files'
open FILE, '$PATH1' or die "Can't open file: $!\n";
my @array = <FILE>;
close(FILE);
foreach $line (@array)
{
print $line;
if ( -e $PATH2/$_ )
{
print $PATH2/$_ "exists \n";
}
else
print $PATH2/$_ "not exists \n";
}
}
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,634
4,562
75
Hint: "$a/$b" returns a string. $a/$b is a division operator.