my %count; for my $record (@records) { if ($count{$record->src}++) { $record->duplicate(1); # or however you set the duplicate flag } }