It did not, nor did an earlier attempt using than Scalar::Util's dualvar. Still I liked my little Empty but True module enough to post it here. (Seems too useless/dangerous/not worth the bother to be on CPAN.)
usage:package MyEmptyTrueVar; our $singleton; use overload fallback => 'TRUE', '""' => sub { "" }, # Return empty string on stringification bool => sub { 1 }, # Return true in boolean context '0+' => sub { 1 }, # Return true in numeric context cmp => sub { !ref $_[1] }; # unequal to empty string, or any other +string bless $singleton=\$singleton;
shows that Single str='', Num=1.say "Single str='$MyEmptyTrueVar::singleton', Num=", (0+$MyEmptyTrueVa +r::singleton) if $MyEmptyTrueVar::singleton && $MyEmptyTrueVar::singleton ne '' && '' ne $MyEmptyTrueVar::singleton;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Empty string but True
by RonW (Parson) on Jan 22, 2015 at 18:57 UTC |