Why am I getting Pseudo Hashes Deprecated?

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} does not exist, so I added a defined function.

$xml is an object if that matters?

How can this be fixed, so Perl does not complain?

+4
source share
1 answer

Either $xml or $xml->{account} is ARRAY, not HASH (you can use ref to check this, see perldoc -f ref ). Perl now had an obsolete function called "pseudo hashes" that allowed access to special arrays through hash syntax. If you care about the story, you can use it on Google or look at the book of older camels.

+11
source

Source: https://habr.com/ru/post/1342646/


All Articles