Perl: Removing NULL characters (0x00)
peter at bowenfamily.org
Fri Mar 4 09:14:14 MST 2005
What you're really looking for is pack/unpack try this...
unpack("A*",$value) - it's pretty common for c++ stuff to marshall a
struct together and send it to you, and perl just sees a really long string.
David Smith wrote:
>I wrote a perl TCP/IP client program that talks to a server. The server
>sends me ASCII over the scoket, but it appends a NULL byte to every string
>(0x00), which I discovered with file redirection and a hex editor (it was
>invisible in the shell output). How can I prune this byte off of the
>string in Perl? I tried chomp, but it appears to only remove \r and \n. I
>also tried s/\s+$// but \s doesn't appear to match the 0x00 character.
>Thanks in advance.
>| This has been a P.L.U.G. mailing. |
>| Don't Fear the Penguin. |
>| IRC: #utah at irc.freenode.net |
More information about the PLUG