Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Entering external data

by moked (Beadle)
on Aug 10, 2003 at 08:06 UTC ( #282576=perlquestion: print w/replies, xml ) Need Help??

moked has asked for the wisdom of the Perl Monks concerning the following question:

Hi All
when I use external data entering
$data = <>;
after entering the data, pressing enter will cause
a line brake, but I want to use this data as a part of a path
which means the line brake souldn't be there.
the question is how do I erase this line Brake ??

Thanks Ahead, Nir

Replies are listed 'Best First'.
Re: Entering external data
by AcidHawk (Vicar) on Aug 10, 2003 at 08:15 UTC

    I think you are looking for chomp ..

    From the perlfunc docs relating to chomp.. "It's often used to remove the newline from the end of an input record ..."

    Update: Here is a Tutorial about Basic Input and Output which might help.

    Of all the things I've lost in my life, its my mind I miss the most.
Re: Entering external data
by ido50 (Scribe) on Aug 10, 2003 at 12:30 UTC
    If you wanna delve more into the subject, read the material AcidHawk gave you. But just for the matter, to erase the linebreak use chop($data = <>); (You can also use chomp instead. chomp erases the last character only if it's a newline. chop erases the last character no matter what.

    Live fat, die young
      chomp erases the last character only if it's a newline
      Kind of but not really. 'perldoc -f chomp' says
      This safer version of "chop" removes any trailing string that corresponds to the current value of $/ ...
      Sure $/ is "\n" by default, but that's besides the point. Also, it's best to make a link to the documentation like chomp or chomp (perldoc:perlfunc:chomp|chomp] or [perldoc://chomp])
        Well to be quite honest I got this sentence ("chomp erases the last...") from the Camel book. It's not a direct quote, that's just what I remembered. I would have looked it up again if I haven't returned the book to my university library last week.
        And about the documentation link, I'll do that from now on.

        Live fat, die young

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://282576]
Approved by gellyfish
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2021-04-14 15:09 GMT
Find Nodes?
    Voting Booth?

    No recent polls found