Let’s say I have a hash like this
my %profile = (
building => $p->{account}->{building},
email => $p->{account}->{email},
phone => $p->{account}->{phone},
);
The variables in $p can have all sorts of values when they have not been defined. I have atleast seen undef ~ ''.
How do I assign a value of -1 to e.g. $profile{building} if $p->{account}->{building} have one of these strange default values?
Are there any clever Perl way to do that?
Update: Any of the values can take on any of the strange default values undef ~ ''.
I would add a function:
and implement the default-filtering logic in the function.
Or, better yet, pre-apply the logic to $p so that you know that $p has reasonable values.