in reply to File that exists won't open
Your input files end in whitespace. Most likely, "Windows"-newlines, that is, \r\n. Your chop removes the last character, which would be the \n, but still leaves the \r at the end of the filename.
Had you used warnings, Perl would've maybe told you about "failed open on filename containing newline".
Just remove all whitespace from the end of your input filenames and retry.
Also, I would adjust the error messages to be more informative by telling you what exactly failed:
my $input_filename= "$ofn.txt"; open(IN,$input_filename) or die "Can't open input file '$input +_filename': $!\n"; my $output_filename= "$nfn.txt"; open(OUT,'>', $output_filename) or die "Can't open output file + '$output_filename': $!\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: File that exists won't open
by cormanaz (Deacon) on Mar 07, 2014 at 13:40 UTC | |
by McA (Priest) on Mar 07, 2014 at 13:46 UTC |