Dear James,

A way to work with that datastructure would be:

my %hash = ...;
my @robots;

for my $ip (keys %hash) {
    my $type = $hash{$ip}{type};

    push @robots, [ $ip, $hash{$ip}{agent} ] if $type eq "robot";
}

I suggest you use an array of hashes, in the form:

my @array = (
    { ip => ...,
      agent => ...,
       type => ...
    },
    ...
);

Then you could do:

my @robots = grep { $_->{type} eq "robot" } @array

There are MANY alternatives.

---

A word about the task:

What happens when multiple agents use the same IP address?

Jonathan Paton

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to