my %seen; for my $thing ($worksheet->...) { next if exists $seen{$thing}; # create XML element $seen{$thing}++; }