Any time you encounter mystery characters in your data, you should do a hex dump so that you know exactly what those characters are (guessing can work, but can bite you later if you guess wrong). If you haven't done so, try replacing this:
@test = split (//,$something); foreach (@test) {print "$_\n";}
with:
for (split //, $something) { printf "%02X ", ord; }
Given the input "J\x00O\x00H\x00N\x00" this will print:
4A 00 4F 00 48 00 4E 00
With that said, as far as I can tell, if your string contains embedded NULLs, your browser should interpret them as whitespace, so that it appears that there is a single space where each NULL character would be expected to appear. This would render your example as: J O H N

If you're not seeing this behavior when interfacing with the CGI, but you are seeing it in the shell, you should probably do some testing to find out if the mystery characters show up in both environments. If not, then there's a problem with the environment in which your script is running (when running from the shell).


In reply to Re: DBI returns NULL characters in string by converter
in thread DBI returns NULL characters in string by jcbyrne

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.