in reply to Why chomp() is not considering carriage-return
Chomp removes the current "input record separator", which can be changed by editing one of the built-in perl variables:
Or you can just use regex to convert the line endings, which is probably safer if you don't know for sure what they're going to be:$/ = "\r\n";
This basically detects what the line endings are from the first line ending, then converts everything to a standard \n.for ("\r", "\n", "\r\n", "\n\r", "\r\r", "\n\n") { $line = 'text'.$_."text"; $line =~ s/$1/\n/g if m/(\r\n?|\n\r?)/; print "$line\n"; }
|
---|
In Section
Seekers of Perl Wisdom