in reply to split on delimiter unless escaped

I use the encode-decode technique given by Roberto Ierusalimschy in Programming in Lua, 20.4 – Tricks of the Trade. The book is freely available on the net. Here are the functions (translated from lua to perl):
{ my $re = qr/\\(.)/; sub encode ($) { my $str = $_[0]; $str =~ s/$re/{ sprintf '\\%03d', ord($1) }/ge; return $str } } { my $re = qr/\\(\d{3})/; sub decode ($) { my $str = $_[0]; $str =~ s/$re/{ '\\' . chr($1) }/ge; return $str } }
For example, after this line
my @splitted = map { decode $_ } split ',', encode('hel\,lo,world')
@splitted becomes ('hel\,lo', 'world'). I believe this is the most universal and easy to use technique. Cheers