Lady_Aleena is (almost completely ) right: at the very least, anything that you get from the user using <STDIN> should be
chomped to get rid of the end of line characters (the only very minor point where she is not completely right is that she has a small typo on the name of the variable, $opt1 instead of $opr1).
This is especially important for the operation ($opr1 variable), that will never be equal to "+" (for example) if you don't chomp it, but more probably to things like "+\n" (under Unix) or "+\r\n" (under Windows) or something else (on Mac, I don't know for sure, it used to be "+\r", but I think it has changed some times ago and is probably like Unix nowadays). Anyway, whatever the trailing character(s) is not so important, the point is that you should remove it using the chomp function.
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.