in reply to Stringifying undefs
In C, #define NULL ((void*)0). In C++, #define NULL (0). In Perl, zero is a number and undef is a completely different scalar concept.
There are many levels of truth in Perl, unlike those other languages. There's non-zero. There's non-empty. There's defined. And the opposite of all of these is undef. (There's even the concept of not existing, which is even less than undef.)
You can have a hash key of '0' and a different hash key of '', even though both are evaluated as "false" when used in a condition. However, you can't have a hash key of undef. Why? Because undef isn't a string, just like it isn't a number.
In short, you will have to change your code to accept these two different values. Or say no warnings; in blocks where you want Perl to read your mind without complaining. But don't expect the computer to read your mind so well as to assume you want '0' when you say undef.
--
[ e d @ h a l l e y . c c ]
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Stringifying undefs
by BUU (Prior) on Mar 02, 2004 at 20:47 UTC | |
by halley (Prior) on Mar 02, 2004 at 22:10 UTC | |
by BUU (Prior) on Mar 02, 2004 at 22:41 UTC |