Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

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

by svenXY (Deacon)
on Oct 02, 2007 at 15:04 UTC ( [id://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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-03-28 12:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found