Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Chomp doesn't work

by davido (Archbishop)
on Mar 25, 2013 at 09:04 UTC ( #1025259=note: print w/ replies, xml ) Need Help??


in reply to Chomp doesn't work

chomp strips from its parameter list the contents of $/, which is typically "\n". However, there are at least five Unicode code points that produce a newline (see perluniprops) Also, "\n" means different things on different machines; a file saved on a Windows system will have a different version of "\n" than a file saved on a Unix/Linux system. This could be getting in your way too.


Dave


Comment on Re: Chomp doesn't work
Download Code
Re^2: Chomp doesn't work
by M15U (Acolyte) on Mar 25, 2013 at 09:22 UTC

    I got it. It's a little embarasing : each end of line has"\r\n" at the end. So by using this replace statement it works :

    $start_input =~ s/\r\n//d;

    So, if you ever get something similar, think about the "\r" before the "\n".

      Just use \R instead!
      $start_input =~ s/\r\n//d;

      /d is not a valid option for s///.    Perhaps you meant tr/\r\n//d?

        /d was added in 5.14.
        لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1025259]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2014-11-28 01:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (191 votes), past polls