Please read instructions when posting -- they say "Put <code> </code> tags around your code and data!" (emphasis in the original text). Note that you can also use <c> and </c>, even within a paragraph.

Here's a demonstration to show how a regex substitution should work to remove null bytes:

s/\x00+//g;
You can also use the "tr///" operator:
tr/\x00//d; # a.k.a. "y///" : y/\x00//d;
To see that in action, consider the following command lines, using perl one-liners (and assuming you have the "xxd" utility for doing a hex dump of stdin -- or some equivalent tool):
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
If you think you really are doing something like that, and it's not working for you, then you'll have to show a working demonstration of the code that proves it doesn't work.

My guess is you're doing something else wrong elsewhere in your code, unrelated to the regex. (If your program doesn't use strict; then it might be something as simple as a spelling error in a variable name.)


In reply to Re: striping nulls by graff
in thread striping nulls by sans-clue

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.