I have a perl assignment I have a question about. I have to take a text file (gettysburgh.txt) and I have to alter it. I think my code is correct but when I run the program it says no such file exists. The file is saved on my computer so I was hoping someone could tell me what I was doing wrong.
#!/usr/bin/perl -w
# Assignment3Ex1.pl
use strict;
open(INFH, '<', 'gettysburgh.txt') or die $!;
open(OUTFH, '>', 'ex1out.txt') or die $!;
while (<INFH>) {
next if /^\s*$/;
my @words = split;
print OUTFH "$_\n" foreach @words;
}
close INFH;
close OUTFH;