http://www.perlmonks.org?node_id=980482


in reply to Problems with formatting the results of my regex

If your log files have CRLF line endings you can also open them for reading via the :crlf layer so that chomp will remove the carriage return as well as the line feed.

knoppix@Microknoppix:~$ hexdump -C xxx.crlf 00000000 4c 69 6e 65 20 31 0d 0a 4c 69 6e 65 20 32 0d 0a |Line 1..L +ine 2..| 00000010 4c 69 6e 65 20 33 0d 0a 4c 69 6e 65 20 34 0d 0a |Line 3..L +ine 4..| 00000020 4c 69 6e 65 20 35 0d 0a |Line 5..| 00000028 knoppix@Microknoppix:~$ perl -E ' > open $in, q{<:crlf}, q{xxx.crlf} or die $!; > while ( <$in> ) > { > chomp; > say qq{>$_<}; > }' >Line 1< >Line 2< >Line 3< >Line 4< >Line 5< knoppix@Microknoppix:~$

I hope this is helpful.

Cheers,

JohnGG