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.

In reply to Re: Help with getting the ouput from the script by greengaroo
in thread Help with getting the ouput from the script by freekngeek

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.