perl - Is hashref in array?
Alan Young
alansyoungiii at gmail.com
Wed Jan 10 04:15:09 MST 2007
Hill, Greg wrote:
> Can't you just do:
>
> my %seen = ();
> my @unique = grep { !$seen{$_}++ } @tree;
Actually this would be more efficient (and perlish):
my @unique = do { my %s ; @s{ @trees } = '' ; keys %s };
> Or am I missing something?
Yeah. He was getting the stringified reference (HASH(0xABCDEF)) as a
key and he wanted the actual data as a key. So you have to serialize
the referenced data for each key and have some way of bringing it back
as a reference of values.
More information about the PLUG
mailing list