in reply to Unique Array Items

Use ++$h{$_} instead of $h{$_}++ so the incrementing is done first, before the compare. $h{$_}++ returns the value, which is numerically 0 the first time through, then increments the value. This causes things seen only once to be ignored.
@toBeMoved = sort {$a <=> $b} grep {++$h{$_} == 1} @toBeMoved;

- Tom

Replies are listed 'Best First'.
Re* Unique Array Items
by Roy Johnson (Monsignor) on Nov 06, 2003 at 21:41 UTC
    Or instead of "this is the first occurrence", use "haven't seen this before":
    ...grep {!$h{$_}++}...