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

Sure. This warning is actually means that $attribute is not defined. You probably calling this method like:

$self->get_attribute
somewhere

Replies are listed 'Best First'.
Re^5: Use of uninitialized value in hash element at
by Anonymous Monk on Apr 27, 2011 at 18:09 UTC
    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.

      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; }