Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Carrige Return and Line Feed in Perl.

by Argel (Prior)
on Mar 01, 2011 at 23:31 UTC ( #890865=note: print w/replies, xml ) Need Help??


in reply to Carrige Return and Line Feed in Perl.

Slightly off-topic, but I got fed up with chomp because I work on files that were generated on e.g. UNIX and then transferred to Windows or vice versa (thanks vendors). These days instead of chomp I use something like $line =~ s/(?:\012)|(?:\015)//g; to get rid CRs and LFs when reading files in.

Update: BTW, nice series of questions and welcome to PM!!

Elda Taluta; Sarks Sark; Ark Arks

  • Comment on Re: Carrige Return and Line Feed in Perl.

Replies are listed 'Best First'.
Re^2: Carrige Return and Line Feed in Perl. (s/\s+$//)
by tye (Sage) on Mar 02, 2011 at 03:46 UTC
    s/\s+$//

    Much better than chomp. Trailing whitespace should never be significant, so don't let it be.

    - tye        

      Will be trying/reading all the suggestions/links.

      Things are a lot clearer now, thank you all for the insight.

      That's a very good point. If it did matter it would be a rare/edge case, so just getting rid of the extra whitespace by default makes sense!!

      Elda Taluta; Sarks Sark; Ark Arks

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://890865]
help
Chatterbox?
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: (4)
As of 2020-05-28 22:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (166 votes). Check out past polls.

    Notices?