On using autodie, it is showing the error message that no such file or directory. But when harcoding the same path, the script is running.
Can't open('FILE', '$filename'): No such file or directory at sblmaint.pl | [reply] |
print '$filename', "\n";
print "$filename", "\n";
And for more information, you can read this tutorial on quotes in perl. | [reply] [d/l] |
This helped a lot. Using double quote and double slash resolved the issue. Thanks a lot.
| [reply] |
In addition to Eilys hint, try
print $filename, "\n";
Note that, if you have your complete filename in a variable, like in your OP (and as you should, as it eases debugging and error messages), quoting it in the open statement is superfluous.
Besides, most Windows functions and many programs accept forward slashes,
so you can write
my $filename="$mydir/file_detail.txt";
open (FILE, "<", $filename);
Update: corrected quotes - d'oh! Thanks AnomalousMonk! | [reply] [d/l] [select] |