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};
}
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};
}
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;
}
You should always post the full example code.....
Not sure what you're doing, but you're probably mixing arrays and array refs and/or hashes and hashrefs. I usually only use references, as I like the syntax better and I like to be consistent:
use strict;
use warnings;
my($arrayrefOfHashrefs) = [
{foo => 'bar',
bar => 'baz'},
{Hello => 'world'},
];
foreach my $href (@$arrayrefOfHashrefs) {
print join("\n", keys %$href);
print "\n\n";
}
will print:
C:\Temp>perl foo.pl
bar
foo
Hello