in reply to Re: Re: text string approxiamtions (concept for review)
in thread text string approxiamtions (concept for review)

grep and map can probably help. First, to get a subset of hash keys:
my @a_keys = grep {/a/} (keys %names);

Then to get their values:
my @a_values = map {$names{$_}} grep {/a/} (keys %names);

You could also get the job done using hash slices, like so:
my @a_values = @names{grep {/a/} keys %names};

That's more like the syntax you proposed, though I find it a bit disconcerting (maybe because I don't find the @names{...} hash-slice notation particularly natural in the first place).

        $perlmonks{seattlejohn} = 'John Clyman';

Update: only answered half the question in my original reply. Fixed here.

Replies are listed 'Best First'.
Re: Re: Re: Re: text string approxiamtions (concept for review)
by shemp (Deacon) on Dec 05, 2002 at 22:58 UTC
    I guess i was really throwing this idea to the monks as something on my wishlist to be internally optimized by Perl's hash implementation. What has been suggested will certainly work, but i was trying to imply that if these sort of operations were part of Perl's hash implementation, they would work faster than methods we now must use to effectively accomplish the tasks suggested.