Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: How to write a program to read stdin or command line?

by svenXY (Deacon)
on Oct 02, 2007 at 15:04 UTC ( #642128=note: print w/ replies, xml ) Need Help??


in reply to How to write a program to read stdin or command line?

Hi,

$ perl -e 'while(true){print"line? >";$line=<STDIN>;chomp $line;print +$line," world\n"}' line? >line1 line1 world line? >sttw rtztrw sttw rtztrw world line? >last line.............. last line.............. world line? > world line? > $ perl -e 'print "@ARGV"," world\n" if $ARGV[0] || do {while(true){pri +nt"line? >";$line=<STDIN>;chomp $line;print $line," world\n"}}' "reve +rse(dlrow) is" reverse(dlrow) is world
like that?
update: adding support for "command-line" (interpreted as "arguments")
Regards,
svenXY


Comment on Re: How to write a program to read stdin or command line?
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2014-07-28 16:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (204 votes), past polls