Hello chiggly007, and welcome to the Monastery!
When the user types (say) “1.5” and presses “Enter”, $price is assigned “1.5\n” (note the newline). Then when print "$price" is called, this newline is printed to the screen.
Solution: chomp the input:
my $price = <STDIN>; chomp $price; print "$price Yens ", ($price / $yen), " pounds\n";
(Also, please fix the <code> / </code> tags in your post so that your script prints clearly. See Markup in the Monastery.)
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
In reply to Re: Question why my code is posting a new line
by Athanasius
in thread Question why my code is posting a new line
by chiggly007
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |