On Wed, Feb 22, 2006 at 03:47:45PM -0800, Ryan Gies wrote:
> I've been frustrated with the "Use of uninitialized value" warning
> myself, and was hoping someone could shed some light on it as well.
> Point being, this will issue the warning:
>
> #!/usr/bin/perl -Tw
> sub max { return $_[0] > $_[1] ? $_[0] : $_[1]; }
> max();
>
> In what seems like logic, the undef value should behave like zero or
> empty string when using operators like: '.' ',' 'eq' 'lt' '>' etc...
The undef value *does* behave like zero or the empty string, as
appropriate. That's why you get a valid result, rather than an error or
undefined behavior. Nonetheless, it is uninitialized, so you also get a
warning.
Ronald