Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Help with getting the ouput from the script

by greengaroo (Hermit)
on Jun 03, 2013 at 17:51 UTC ( #1036815=note: print w/ replies, xml ) Need Help??


in reply to Help with getting the ouput from the script

Fellow monks, please, for a simple question, give a simple answer.

Monk freekngeek, what you want to do is to read from the command-line from your script. This is part of the input/output chapter. The output part, you probably know already. When you use the print function, you use the output.

To use the input and output in Perl, you need what is called "FileHandles". The print function uses a default FileHandle named "STDOUT" (Standard Output).

You want to read from the STDIN (Standard Input). How to do that? Try this:

my $a = <STDIN>;

It will give the same result as Monk hippo mentioned above. In his example, the STDIN FileHandle was implied, the same way the STDOUT FileHandle is implied when you use the print function:

print "Hello world";

Is the same as:

print STDOUT "Hello world";

Of course, you can use CPAN modules to achieve reading from the command-line, like Monk davido mentioned above, but I suggest before you venture in that direction, that you learn the basics of Input/Output in Perl. Search for "FileHandle" and "STDIN" and you shall find your answers.

A for will get you from A to Z; a while will get you everywhere.


Comment on Re: Help with getting the ouput from the script
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (15)
As of 2014-08-28 16:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (264 votes), past polls