Perl: Removing NULL characters (0x00)

Doran Barton fozz at iodynamics.com
Fri Feb 25 11:34:38 MST 2005


Not long ago, David Smith proclaimed...
> 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.

You could try chop (the old, less smart and more dangerous version of chomp).
-- 
fozz at iodynamics.com is Doran L. Barton, president, Iodynamics LLC
Iodynamics: Linux solutions - Web development - Business connectivity
 "Guests are requested not to smoke or do other disgusting behaviours in
  bed."
    -- Tokyo hotel's rules and regulations
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://plug.org/pipermail/plug/attachments/20050225/00a87bf9/attachment.bin 


More information about the PLUG mailing list