Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

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

by ikegami (Pope)
on Oct 02, 2007 at 15:27 UTC ( #642138=note: print w/ replies, xml ) Need Help??


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

I don't see why -i is required. If it's not on the command line, then it must be on STDIN, so there's no reason to use -i.

my $input = @ARGV ? shift(@ARGV) : <STDIN>;

That's the approach <ARGV> uses.


Comment on Re^2: How to write a program to read stdin or command line?
Select or Download Code
Re^3: How to write a program to read stdin or command line?
by jdporter (Canon) on Oct 02, 2007 at 17:50 UTC

    Scalability / future expansion. The program may need other data on the command line unrelated to the need stated in the OP.

    Anyway, I didn't say -i is required. I answered the question "How would you...." And this is how I would. If you would do it otherwise, fine.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (6)
As of 2014-12-25 23:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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





    Results (163 votes), past polls