By the way,
my %seen; my @uniq; foreach my $item (@lines) { unless ($seen{$item}) { #if we get here, we have not seen it before $seen{$item} = 1; push(@uniq, $item); } }
can be written as
my %seen; my @uniq = grep !$seen{$_}++, @lines;
In reply to Re: finding unique items in an array, from a text file
by ikegami
in thread finding unique items in an array, from a text file
by spazmospazmo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |