$/ = "\xa"; while( ) { s/\xd?\xa$//; # does what chomp would do, handles CRLF and LF-only for my $line ( split /\xd/, $_, -1 ) # handles CR-only cases { # now we're line-oriented no matter what the input style is... } }