abufct has asked for the wisdom of the Perl Monks concerning the following question:
Hi!
I am trying to solve a well-known problem of extracting unique values from array. I am using the following code for this:
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
Back to
Seekers of Perl Wisdom