I ran up against the inability of the script to stop for the keystokes.

So, are you saying that it is still the case, when you run "example2.pl" as a shell command line (i.e. in a Terminal window or xterm), the script does not wait for input from the keyboard? I don't get that sort of behavior on my mac -- I stored the four-line script to a file called "example2.pl", just as you posted it, and when I run "example2.pl" as a command in a shell, it shows the prompt, waits for me to hit "return", and echos whatever I typed before hitting "return".

If you were running the script with input redirection ( example2.pl < some.file ) or if you were piping data from some other process to the script ( other_process | example2.pl), then of course the script won't wait for input from the keyboard, because STDIN is tied to a file or a pipe, respectively. But you probably knew that already, being familiar with unix.

Also (of course) if you type "example2.pl" at the shell prompt, and then hit "return" twice in a row, the second return will be taken as input at line 3 of the script, and it will finish, echoing an empty string.


In reply to Re^3: STDIN under MAC OS 10.4.11 by graff
in thread STDIN under MAC OS 10.4.11 by AliceQuint

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.