Here's a suggestion for future development -- instead of creating the filename to be opened just in the open statement, create it ahead of time:
You may hear about using autodie instead, but I like writing out the open statement and the die statement, as it gives the debugger me more information from the developer me. In this case, if it fails, you can immediately copy and paste the filename into an ls command and check to see if Perl can't find the file .. or if developer me is an idiot. :)my $filename = # complicated work that builds filename open ( my $fh, '<', $filename ) or die "Unable to open $filename for read: $!"; # ... close ( $fh );
In reply to Re^3: 'open for read' fails as "no such file or directory" but file is there
by talexb
in thread 'open for read' fails as "no such file or directory" but file is there
by fasoli
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |