note
greengaroo
<p>BrowserUk is right, don't use a module to do that if you can do it with one line of code! Grep receives <del>an array</del> a LIST and returns <del>an array</del> a LIST. The returned array will be shorter, but the elements will be added in the order in which they are encountered in the other array.</p>
<p>Imagine you do this:
<code>
@array1 = @array2;
</code>
The elements in @array1 will be in the same order has in @array2, right?
</p>
<p>Now do this:
<code>
foreach $element ( @array2 ) {
push( @array1, $element );
}
</code>
The elements in @array1 will still be in the same order has in @array2, don't you think?
</p>
<p>And if you do this:
<code>
foreach $element ( @array2 ) {
if ( not $seen{$element} ++ ) {
push( @array1, $element );
}
}
</code>
Guess what? The elements will still be in the same order and I just explicitly did what grep do in one line.
</p>
<div class="pmsig"><div class="pmsig-823564">
<div class="pmsig">
<i>There are no stupid questions, but there are a lot of inquisitive idiots.</i><br/>
<div class="pmsig-823564">
-- [id://823564]
</div></div>
</div></div>
997453
997466