in reply to Re^4: Use of uninitialized value in hash element at
in thread Use of uninitialized value in hash element at

Hi,

thanks for response. I know what is causing this, but I'd just like to return undef if it doesn't exists and value if it exists.

Why can't I do that without getting this warning ?

It's not clear to me, why I can't "just ask politely" if it exists and return undef if it doesn't without warning...

Thanks in advance, regards, Bulek.
  • Comment on Re^5: Use of uninitialized value in hash element at

Replies are listed 'Best First'.
Re^6: Use of uninitialized value in hash element at
by zwon (Abbot) on Apr 28, 2011 at 12:44 UTC

    undef is invalid value for hash key, since this warning. If you don't want to see it you can check if $attribute defined or not:

    sub get_attribute { my ( $self, $attribute ) = @_; return defined($attribute) ? $self->{ATTRIBUTES}{$attribute} : und +ef; }