s/\x00+//g; #### tr/\x00//d; # a.k.a. "y///" : y/\x00//d; #### perl -e 'print "foo\x00bar" | xxd -g 1 # produces this output (note the null byte): 0000000: 66 6f 6f 00 62 61 72 foo.bar perl -e 'print "foo\x00bar" | perl -pe 's/\x00+//g' | xxd -g 1 # produces this output (no null byte): 0000000: 66 6f 6f 62 61 72 foobar