[wplug] Perl split on null?
Jonathan S. Billings
wbanguna at gmail.com
Wed May 21 13:12:26 EDT 2008
On Tue, May 20, 2008 at 03:50:32PM -0400, larry at daberko.com wrote:
> I figured it out.
>
> split (/\0/, $value) worked.
>
> Apparently, this isn't widely used. :-P
Actually, I use a very similar split for parsing a couple data formats
that are null-delimited, although I use split("\0",$value), no point
doing a regex in this case unless you expect a variable number of null
bytes between records.
However, using split(//,$value) might be unexpected because the //
regex pattern isn't for the null byte (\0) but for *nothing*. There
is an infinite sequences of nothingness between each byte,
fortunately, Perl is smart enough to only split on the first nothing
it finds, otherwise you'd be waiting for a while.
--
Jonathan Billings <wbanguna at gmail.com>
More information about the wplug
mailing list