The variable $price contains all of your input, which includes the new line (Enter). When you print it out as a string in the last line, the new line is printed as well. This doesn't happen later in that line when the price in pounds is printed because you are printing the result of an arithmetic calculation, and the newline is silently dropped (from both $price and $yen) when they are treated as numbers instead of strings ... no they don't cancel out ;-).
There is a command in perl specifically for stripping the Enter key results from your input: chomp. Although it is related to chop, which shmem suggested, it is superior for this purpose because it will work on different platforms (Unix, Windows, Mac OS, etc). chop will not give you what you want in Windows (for example), where the enter key appends two characters.
The intelligent reader will judge for himself. Without examining the facts fully and fairly, there is no way of knowing whether vox populi is really vox dei, or merely vox asinorum. — Cyrus H. Gordon
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
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:
Outside of code tags, you may need to use entities for some characters:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||