in reply to Removing doubles and printing only unique values
Hi zarath. $seen{$fields[1]} is always going to be false unless you set it to true. One possible way to do what you want is:
$seen{$vk}++ will first return the current value (ie 0 the first time), and then increment it by one, so the value will be true from that point. By the way, I also changed your split, you can affect the output of split directly to a list, with undef in the place of elements you want to ignore. And split will be optimized to stop splitting after the list is full (eg: here you only have two elements on the left, so it will only split twice).(undef, my $vk) = split ";" , $line; # define input-lines push (@vk,$vk) unless $seen{$vk}++;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Removing doubles and printing only unique values
by zarath (Beadle) on Oct 31, 2017 at 13:15 UTC | |
by Eily (Monsignor) on Oct 31, 2017 at 13:41 UTC |