Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do I get "Pseudo-hashes are deprecated"?

Tags:

perl

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?

like image 288
Sandra Schlichting Avatar asked Dec 22 '22 17:12

Sandra Schlichting


1 Answers

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.

like image 200
Dave Goodell Avatar answered Dec 24 '22 05:12

Dave Goodell