in reply to undef vs empty string '' from split
The seperator is matched, so it must be seperating two things. One of them must therefore be "". It allows the following three cases to be distinguished: a=b vs a= vs a.
for ('a=b', 'a=', 'a') { my ($p1, $p2) = split(/=/, $_, 2); print( "$_\t", ( !defined($p2) ? 'undef' : !length($p2) ? '""' : qq{"$p2"}, ), "\n" ); }
a=b "b" a= "" a undef
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: undef vs empty string '' from split
by chrism01 (Friar) on Jun 21, 2007 at 01:15 UTC |