in reply to Capturing Unique Data
my @nc; my %seen; while (<$fh>) { chomp; push @nc, $_ if !$seen{$_}++; }
Or if your input is guaranteed to be sorted,
my @nc; my $last; while (<$fh>) { chomp; push @nc, $last = $_ if !defined($last) || $last ne $_; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Capturing Unique Data
by donkost (Initiate) on Aug 19, 2009 at 15:29 UTC |