my $file = "test.txt"; my $count = "0"; open (FILE, $file) or die "Error $!"; my $words = ; $count++ for split /\s+/, $words; print "Count: $count\n"; print "Words: $words\n"; close FILE;