in reply to Unique values in array
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
|
|---|