Perl: Removing NULL characters (0x00)

Corey Edwards tensai at zmonkey.org
Fri Feb 25 11:52:33 MST 2005


On Fri, 2005-02-25 at 11:22 -0700, 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.

What about this:

        s/\x00$//;

Corey

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://plug.org/pipermail/plug/attachments/20050225/11faf481/attachment.bin 


More information about the PLUG mailing list