David Corbin wrote:
> raptor wrote:
> > 
> > $hash{/re/} i.e. this is the same like
> > 
> > my @res;
> > foreach my $k (keys %hash)
> >  {
> >   if ($k =~ /re/) {push $hash{$k},@res}
> >  };
> > 
> > OR
> > keys %hash{/re/}
> > values %hash{/re/}
> > each %hash{/re/}
> 
> Way cool.  I'd love this.  

Well, $hash{/re/} would only evaluate to a single scalar.
More likely, you'd want  @hash{/re/}, which would be
equivalent to  @hash{ grep { /re/ } keys %hash }.

So  values %hash{/re/}  is unnecessary, since it would
be the same as @hash{/re/}.

And  keys %hash{/re/}  would be the same as
grep {/re/} keys %hash -- a very small gain, imho.

The proposed  each %hash{/re/}  wouldn't work, even given
hash slices like  %hash{@keys}, since each needs an actual
hash object to attach to; and slices aren't.

-- 
John Porter

        We're building the house of the future together.

Reply via email to