Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re^3: Initialized Variable getting Uninitialized Warningby pryrt (Abbot) |
on Feb 27, 2019 at 18:15 UTC ( [id://1230627]=note: print w/replies, xml ) | Need Help?? |
exception => undef ikegami pointed out the likely culprit. But if you hadn't seen that, then what you just said is the opposite of what I would do after reading >>"Uninitialized" really means "has undef for value"<< in ikegami's first post. My recommendation would have been to figure out why the exception-key's value was being set to undef, not intentionally force it to undef. To do that here, I would have made a print statement (This is step#2 from Basic debugging checklist) printf STDERR "ref=%s, exception->{exception}=%s\n", $exception, $exception->{exception}//'<undef>';... and placed it right before the return($exception) in your subroutine and just after the my $exception = EcomImportUtilities::ageCheck(...). This would have shown you that it was properly defined in the sub, but the hashref wasn't getting into the local $my exception at all, which would have pointed you toward ikegami's conclusion that the conditional-my was what was messing with you -- or, at least, you could have asked "why is $exception a proper hashref in the sub, and not after the subroutine-call?", at which point, ikegami would have chimed in. Hope this helps you for future debugging (edit: move the step#2 comment to subsequent paragraph, where it fits better)
In Section
Seekers of Perl Wisdom
|
|