Hej,
You probably didn't see this (marked with ####)
open(my $fh, "<", $ARGV[0]) or die "cannot open input file: $!";
my @words = <$fh>;
close $fh or die "cannot close input file: $!"; ##############
my $words = @words;
On the other hand, I don't understand the last line - you read a file into array with my @words = <$fh>; and then you assign it to a scalar variablemy $words = @words;. OK, you probably have your own reasons for that but you could manipulate array as good as scalar. And you could read a file directly in a scalar variable. my $words = <$fh>; |