Discussion:
"Pseudo-hashes are deprecated" error and accessing a hash of hashes
(too old to reply)
e***@mindspring.com
2006-01-30 21:04:15 UTC
Permalink
OK, so I see that this is a Perl 5.8 change. I am getting this
"Pseudo-hashes are deprecated" error while following the Camel Book v3
and trying to generate a count of items in a hash of hashes thus:

scalar(keys %{ $logips{$key} } )

Basically I'm parsing a Web log file and am trying to keep a list of
unique IPs that visited each page (modifying Perl Cookbook recipe 4.6)
thus:

my %logips=();
my %logipseen=();
foreach $snifferlog (@ARGV) {
blah blah blah;
push (@{ $logips{$logfile} }, $logip) unless (
$logipseen{ $logfile }{ $logip } )++;
}
foreach $key (@logfiles) {
print scalar(keys %{ $logips{$key} } );

So $logips{$key} should have a hash of all the unique IPs in it, I just
want a quick count, but I'm having trouble with the hash of hash
syntax. Apparently the older syntax in the camel book's not good any
more and I've fiddled aroudn with this a while and read Web tutorials
on hashes of hashes without luck. Any help welcome!

Thanks,
Ernest
Ch Lamprecht
2006-01-30 21:27:38 UTC
Permalink
Post by e***@mindspring.com
OK, so I see that this is a Perl 5.8 change. I am getting this
"Pseudo-hashes are deprecated" error while following the Camel Book v3
scalar(keys %{ $logips{$key} } )
Basically I'm parsing a Web log file and am trying to keep a list of
unique IPs that visited each page (modifying Perl Cookbook recipe 4.6)
my %logips=();
my %logipseen=();
blah blah blah;
------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
that's a hash of arrayrefs
Post by e***@mindspring.com
$logipseen{ $logfile }{ $logip } )++;
}
print scalar(keys %{ $logips{$key} } );
So $logips{$key} should have a hash of all the unique IPs in it, I just
want a quick count, but I'm having trouble with the hash of hash
syntax. Apparently the older syntax in the camel book's not good any
more and I've fiddled aroudn with this a while and read Web tutorials
on hashes of hashes without luck. Any help welcome!
Thanks,
Ernest
HTH Christoph
--
perl -e "print scalar reverse q/***@ergn.l.hc/"
e***@mindspring.com
2006-01-31 04:40:06 UTC
Permalink
Thanks Christoph! That fixed me up. Yes, I was doing a hash of lists
and not a hash of hashes, I got confused since I was also doing a hash
of hashes.

Ernest

Paul Lalli
2006-01-30 21:32:45 UTC
Permalink
Post by e***@mindspring.com
OK, so I see that this is a Perl 5.8 change. I am getting this
"Pseudo-hashes are deprecated" error while following the Camel Book v3
scalar(keys %{ $logips{$key} } )
Basically I'm parsing a Web log file and am trying to keep a list of
unique IPs that visited each page (modifying Perl Cookbook recipe 4.6)
my %logips=();
my %logipseen=();
blah blah blah;
Please don't do that. Post a short-but-*complete* script that we can
run by copy and pasting. Based on what you've shown, I have to
conclude that your real problem is within this blah blah blah.
Where idd $logfile and $logip come from?
Post by e***@mindspring.com
$logipseen{ $logfile }{ $logip } )++;
}
Where did @logfiles come from? You never declared or added to it
before now.
Are you sure you didn't mean
foreach my $key (keys %logips}
?
Post by e***@mindspring.com
print scalar(keys %{ $logips{$key} } );
So $logips{$key} should have a hash of all the unique IPs in it
How do you figure that? Above, you said that $logips{$key} is a
reference to an array. You said that when you dereferenced it as an
array:
push (@{ $logips{$logfile} }, $logip)

But now you're trying to use it as a reference to a hash. As a guess,
I'd say this is the cause of your pseudo-hash error. If you want the
number of elements in this array, get it the same way you get the size
Post by e***@mindspring.com
, I just
want a quick count, but I'm having trouble with the hash of hash
syntax. Apparently the older syntax in the camel book's not good any
more
No. The syntax for getting at your hash-of-hashes has never changed.
It is pseudo-hashes that are being driven out of the language.
Post by e***@mindspring.com
and I've fiddled aroudn with this a while and read Web tutorials
on hashes of hashes without luck. Any help welcome!
You're going to need to post real code if you want real help. In the
meantime, allow me to suggest you print out your structure with
Data::Dumper to see what it actually contains.

use Data::Dumper;
print Dumper(\%logips, \%logipseen);

Paul Lalli
Loading...