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        

      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

      Will be trying/reading all the suggestions/links.

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