$textfield =~ s/\015\012|\015|\012//g; If you prefer hex to octal :-) $textfield =~ s/\xD\xA|\xD|\xA//g;