use warnings; use strict; my $counter = 0; my %hash; while (<DATA>) { my @splits = split; my $snp = $splits[0]; $counter++ if not exists $hash{$snp}; print "$counter $snp\n"; $hash{$snp}++; } __DATA__ foo abc foo cde bar xyz
Prints:
1 foo 1 foo 2 bar
In reply to Re: only increment counter if the ID has not been seen before
by toolic
in thread only increment counter if the ID has not been seen before
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |