$text =~ tr/\r\n//d; # using tr/// $text =~ s/[\r\n]+//g; # using s/// #### # Contains a linefeed if ($text =~ /\n/) { # Also contains a carriage return if ($text =~ /\r/) { print "Seems like DOS text.\n"; } else { print "Seems like unix text.\n"; } } else { print "No linefeeds detected in the text.\n"; }