Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1036815]
and God said, "Let Newton be!"...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2018-06-23 03:31 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (125 votes). Check out past polls.