Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Re: chomp() problems

by paulbort (Hermit)
on Sep 25, 2002 at 21:06 UTC ( #200736=note: print w/replies, xml ) Need Help??

in reply to Re: chomp() problems
in thread chomp() problems

I just ran into this recently with files being FTP'd from Windows to Linux, and I have to agree with Flexx: \r and \n are system-specific, where this is a byte-specific problem. What I used was similar to charnos' substitution, but fixed to ASCII:
$line =~ s/\xD|\xA//g;

This removes all stray CR/LF from any ASCII to any ASCII. (Sorry, no EBCDIC support.) As long as Perl can figure out where the line breaks are, this will get rid of the odd bits.

Spring: Forces, Coiled Again!

Replies are listed 'Best First'.
Re^3: chomp() problems
by Flexx (Pilgrim) on Sep 25, 2002 at 23:08 UTC

    Yup. Some like it hex... ;)

    Update: Actually, what you wrote is EBCDIC compatible. It'll substitute DOS CRLF's on any system, be it an ASCII or an EBCDIC one. You're using discrete ordinals (hexadecimal ones, in your case) instead of the infamous logical symbols \r\n, and that's what makes your statement portable.

    So long,

    PS: Someone downvoted this node (it's -1 by the time of this writing). Why? What did I do wrong here?

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (6)
As of 2022-11-29 08:45 GMT
Find Nodes?
    Voting Booth?