my %seen; while (...) { next if $seen{$_}++; print; }