perl -pe 's/\t/\\t/g' infile > outfile #### my %mapping = ( # or whatever you like to display "\t" => '\t', "\n" => '\n', " " => '_', ); my $pattern = qr/([@{[join '', keys %mapping]}])/; while ( <> ) { s/$pattern/$mapping{$1}/g; print "$_\n"; # you still want to start a new line }