Welcome to the Monastery | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I have a Moose class with an attribute that is not required. When I try to
access this attribute in an object where it is not present, the warning message
"Use of uninitialized value in concatenation (.) or string"
is generated. How can I check for the presence of an optional attribute
without generating the warning message?
The sample code below is a simple Moose class with 1 required attribute (name) and 1 optional attribute (age). The 'show_person' method generates the warning message because $self->age() is not present in the current object.
Just referencing $self->age() in 'show_person' to test it generates the warning, as in:
"Its not how hard you work, its how much you get done." In reply to Checking for Presence of Optional Attribute in Moose Object by roho
|
|