The problem is that it is important to preserve the order in which elements appeared in the original array. So my question: is it guaranteed that grep will execute code blocks for each element from @set in order? I could not find that this is directly stated in the docs.my @set = qw(a b c a c); my %seen; my @unique = grep { not $seen{$_} ++ } @set; # http://www.perlmonks.org/?node_id=614322
In reply to Order in which grep/map receive elements by abufct
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |