Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: read file from ARGV

by Kenosis (Priest)
on Feb 02, 2013 at 07:24 UTC ( #1016664=note: print w/ replies, xml ) Need Help??


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;


Comment on Re: read file from ARGV
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1016664]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (14)
As of 2014-12-22 18:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (126 votes), past polls