On or about Tue, Jul 16, 2002 at 11:47:29AM +0200, Stefan Svensson typed:
>Sorry for bothering you with a simple, off-topic question to which I can't
>find any answer elsewhere.
>
>Can someone provide a simple one-liner to convert a array-of-hashes to an
>array of values for a specified hash key?
Do I understand correctly what you're after? You have:
@a=({a => 1, b => 2, c => 3},{a => 4, b => 6});
and you want a function such that fn (@a, 'a') = (1,4)?
my $p='a';
my @output=map {exists($_->{$p})?$_->{$p}:()} @a;
(Note that you seem to be using the old mailing list.)
Roger
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]