Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Perl warn me about using pseudo-hashes?

Tags:

warnings

perl

Perl is warning me about using pseudo hashs in my program:

Pseudo-hashes are deprecated

How do I convert the following code so that is does not use pseudo hashs

    foreach my $hash (@arrayOfHash) {
            print keys %{$hash};
    }
like image 493
Michael Shnitzer Avatar asked Dec 07 '22 05:12

Michael Shnitzer


1 Answers

The problem isn't in that code. The problem is that @arrayOfHash actually contains arrayrefs, not hashrefs.

If for some reason you can't fix @arrayOfHash, you can work around it by doing:

foreach my $hash (@arrayOfHash) {
     my %hash = @$hash;
     print keys %hash;
}
like image 124
chaos Avatar answered Jan 05 '23 14:01

chaos