map($action1->($_), @arr); #### my %cache; sub routine { my $s = shift; $s->{_xp}->process(); my @arr = $s->{_xp}->getvalues("packet"); map{ $cache{ $_ } ||= $action1->($_) } @arr); }