<?xml version="1.0" encoding="windows-1252"?>
<node id="997453" title="Order in which grep/map receive elements" created="2012-10-05 07:48:44" updated="2012-10-05 07:48:44">
<type id="115">
perlquestion</type>
<author id="997448">
abufct</author>
<data>
<field name="doctext">
Hi!
I am trying to solve a well-known problem of extracting unique values from array. I am using the following code for this:

&lt;code&gt;
my @set = qw(a b c a c);
my %seen;
my @unique = grep { not $seen{$_} ++ } @set;
# http://www.perlmonks.org/?node_id=614322
&lt;/code&gt;

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.</field>
</data>
</node>
