koaps has asked for the wisdom of the Perl Monks concerning the following question:
Hi guys,
I'm trying to figure out how to dereference something and I can't get the syntax right.
I have a hash reference I'm filling up with username => @logins basically.
What I can't seem to get right:my $matches = {}; $matches->{$user} = [grep {/$user/} @logins];
Gives me:foreach my $user (keys %$matches) { print "$user: ". @{$matches->{$user}} . "\n"; }
It should be more like:user1: 1 user2: 0 user3: 0
How can I get at the array values in the hashref?user1: Thu Nov 5 18:49:39 2009 [pid x] [user1] OK LOGIN: Client "127. +0.0.1"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help with a dereference
by Anonymous Monk on Nov 06, 2009 at 19:39 UTC | |
by AnomalousMonk (Archbishop) on Nov 06, 2009 at 19:55 UTC | |
by koaps (Novice) on Nov 06, 2009 at 20:12 UTC | |
by koaps (Novice) on Nov 06, 2009 at 19:54 UTC |