http://www.perlmonks.org?node_id=1016664


in reply to read file from ARGV

Try the following (assuming each word is on a separate line):

use strict; use warnings; chomp( my @strings = <> ); print "$_\n" for @strings;

Usage: perl script.pl word.txt

Update: In case your words are separated by spaces like "foo bar fish cat one two three," even if there are multiple lines, try the following:

use strict; use warnings; my @strings; while (<>) { push @strings, split ' '; } print "$_\n" for @strings;