in reply to split on delimiter unless escaped
For example, after this line{ 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 } }
@splitted becomes ('hel\,lo', 'world'). I believe this is the most universal and easy to use technique. Cheersmy @splitted = map { decode $_ } split ',', encode('hel\,lo,world')
|
|---|