Use the following:
#!/perl/bin
my @words;
open(FILE, "<file.txt") or die("Can't open file.");
while($currentline = <FILE>) {
chomp($currentline);
push(@words,$currentline);
}
close(FILE);
foreach $word (@words) {
print $word." ";
}
print "\n\nDone. Hit RETURN to exit...";
$exit = <STDIN>; Taa-daa.