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}++;
In reply to Re: Removing doubles and printing only unique values
by Eily
in thread Removing doubles and printing only unique values
by zarath
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |