I have this code
if (defined($xml->{account}->{p}) == '2') {
...
}
which gives me this warning
Pseudo-hashes are deprecated at a.pl line 48.
The problem is that in some cases $xml->{account}->{p}
doesn't exist, which was why I added the defined
function.
$xml
is an object, if that makes a difference?
How can this be fixed, so Perl doesn't complain?
Either $xml
or $xml->{account}
is an ARRAY, not a HASH (you can use ref
to check this, see perldoc -f ref
). Perl had a now-deprecated feature called "pseudo-hashes" that allowed special arrays to be accessed via hash syntax. If you care about the history, you can google around for it or look at an older-edition camel book.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With