in reply to Re^3: Undefined vs empty string (not length)
in thread Undefined vs empty string
5.12? *sigh* I've adopted that idiom too quickly, then. We are still at 5.10 at work (and 5.10 was brand new at the point we started the process of upgrading to a new Perl so it may well be a while before we finish the next jump in version numbers even if we started that right now -- though I expect the next attempt to happen significantly faster given the lack of Solaris and not also doing an upgrade from Apache 1 to Apache 2).
Though, I find that in a large majority of cases, '0' is not a meaningful value and so "! $s" and "$s || ..." are just fine. But it is annoying that the only moderately infrequent case of "undef and empty string mean 'unset' but '0' does not" requires testing the variable twice in order to deal with it (without risk of warnings).
Some readers might like to know that using "not length $s" can easily bite one in quite mundane situations. I'd only use "! length $s".
- tye
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Undefined vs empty string (! length, v5.12)
by Anonymous Monk on Jun 05, 2013 at 06:55 UTC | |
by tye (Sage) on Jun 05, 2013 at 07:29 UTC | |
by Anonymous Monk on Jun 05, 2013 at 08:03 UTC | |
by Anonymous Monk on Jun 05, 2013 at 08:11 UTC |