A
Anno Siegel
Tore Aursand said:I know this approach, but I also know that one shouldn't use 'map' in void
context.
This is a contested issue. In particular, there is a patch in the pipeline
so that "map" in scalar context no longer builds a list. A pity Abigail
seems to have left us, she would have had something to say on the subject
However, this one is easily repaired. Either, don't call "map" in void
context:
@common = map { exists $ListB{ $_} ? $_ : () } keys %ListA;
Or use "for" instead:
exists $ListB{ $_} and push @common, $_ for keys %ListA;
Both are probably best expressed as
@common = grep exists $ListB{ $_}, keys %ListA;
which we already know.
Anno