I started a thread last week with a problem that i have since figure out. Now my problem is this. I need to take a file called "gettysburg.txt" and make it so each word is printed on its own line in a new text file called ex1out. When I run the program the file ex1out is created but nothing is in it. The code below is exactly how the text we are using tells us to do it but the words do not print. Any help would be great. My code is this:
#!/usr/bin/perl -w
# Ass3Ex1.pl
use strict;
open(FILE, '<', 'gettysburg.txt') or die$!;
open(OUTFH, '>', 'ex1out.txt') or die $!;
while (<FILE>)
{
next if /^\s*$/;
my @words = split;
print OUTFH "$_\n" foreach @words;
}
close FILE;
close OUTFH;