Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: Output split over two lines

by idsfa (Vicar)
on Dec 23, 2006 at 17:47 UTC ( #591462=note: print w/replies, xml ) Need Help??

in reply to Output split over two lines

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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://591462]
[Corion]: LanX: Ah, yeah - Frankfurt is in the quake region, but at the very border. I think I've never noticed a quake in Frankfurt myself
[marto]: good morning all
[Corion]: On another topic, in the process of Rubber Duck SoPWing, I wrote a post about the best API for generating HTTP requests (not sending them) and while writing it and fleshing out my sample implementation, I came up with some improvements to my ...
[Corion]: ... existing prototype. Cartesian Products will be proud of that module once it gets out ;)
[Corion]: Hi marto ;)

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (9)
As of 2017-01-18 10:16 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (161 votes). Check out past polls.