My file's name is "rootpass" and I am trying to read it like this,
my $rootpass;
my $passfile = "$jobDir/\rootpass";
print "file name = $passfile\n";
if( -e $passfile)
{
open ROOTPASS, '$passfile';
$rootpass = <ROOTPASS>;
print "$rootpass\n";
}
else
{
print "No read permissions on password file $passfile\n";
exit 1;
}
I get an error like this,
Unsuccessful stat on filename containing newline at ReadFile.pl line 106.
106 is the if() line. I have tried the following,
- made it
my $passfile = "$jobDir\/rootpass";
to escape the escape char - made it
my $passfile = "$jobDir//rootpass";
to escape the 'r' so it wont think I have a return char in the file name
How do I read the file whose name is rootpass
under the directory name contained in the variable $jobDir
?