Well, chomp removes the input record separator (see $/ in perlvar). My guess is that your input record separator is "\n", but your input from <STDIN> has a "\r" in it. So, after $var = <STDIN>, $var ends in either "\r\n" or just "\r". You can take them off like this:
$var =~ s{ \r \n ? \z }{}xms;
As an aside, I think using CGI is somewhat misplaced here. If you're on your way to making a CGI script, your input will almost certainly be entirely handled by the CGI module, and you won't need to worry about how your lines are terminated.
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.