in reply to Perl Idioms Explained - keys %{{map{$_=>1}@list}}
In the same category, to see if $bar is in @foo:
or faster and using less memory:my %foo = map { $_ => 1 } @foo; if ($foo{$bar}) { ... }
my %foo; undef @foo{@foo}; if (exists $foo{$bar}) { ... }
Of course, for a single test, grep is easier and often faster:
if (grep $_ eq $bar, @foo) { ... }
Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }
|
---|
In Section
Meditations