Hi
I am a new user here and this is my first posting. I am writing a snippet of code to read an input string from command line. Here is the snippet I use :
$text=$ARGV[0];
print "$text\n";
This reads the value of ARGV[0] into a variable and prints it. If I give it an input of "This is $200", the print out is
"This is 00"
I understand that this happens because perl interprets $2 like a (reg-ex) variable rather than a dollar value (money). Printing $text with a single quote will not interpolate the $text variable.
How can I read a line from input stream with a dollar in it??
Any help is appreciated.
Thanks
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.