Nothing wrong with macosx -- it behaves like any other unix system as far as perl is concerned. So maybe if you show us more information... What is the command line you use to run the script? You showed us three lines of code... Is that all there is to the script?
Here are some examples of shell commands that execute the three lines of perl code you showed us, and these all work for me, using command lines in a Terminal shell window (or in an xterm shell) -- I'm showing the shell prompt ("bash$ ") so that you can see which lines are command-line inputs that I typed; the lines that don't start with "bash$ " are the command outputs.
bash$ perl -e 'print "What is your name? "; $name = <STDIN>; print "Yo
+ur name is $name\n"'
What is your name? Me
Your name is Me
bash$ cat test.perl
#!/usr/bin/perl
print "What is your name? ";
$name = <STDIN>;
print "Your name is $name\n";
bash$ chmod +x test.perl
bash$ test.perl
What is your name? You
Your name is you
So, what are you doing that is different from those examples?
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.