Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re: detecting an undefined variableby Athanasius (Archbishop) |
on Sep 21, 2019 at 13:21 UTC ( [id://11106482]=note: print w/replies, xml ) | Need Help?? |
Hello LloydRice, What you are trying to do is quite possible:
Output:
But, as haukex and LanX have said, the fact that you want to do this strongly suggests that there is a flaw in your design. Update: return eval $scale ? $scale : $default; should be return eval defined $scale ? $scale : $default; to catch the case where $scale exists but has a false value ($state = 0). Note that this approach can’t be used to catch the case where $state exists but has the value of undef. Hope that helps,
In Section
Seekers of Perl Wisdom
|
|