You can print unique values in array order using a variation on the standard hash trick:
my %unique; @unique{@values} = (); for (@values) { next unless exists $unique{$_}; print $_, $/; delete $unique{$_}; }
Update: A simpler way that leaves you with the %unique hash populated:
my %unique; for (@values) { next if exists $unique{$_}; print $_, $/; $unique{$_}++; }
After Compline,
Zaxo
In reply to Re: Unique values in array
by Zaxo
in thread Unique values in array
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |