foreach my $ship (@shipsInCombat) { # Add ship to initiative hash push @shipsToAct, (($ship) x ($ship->{thruster}*2+1)); } shuffle(\@shipsToAct); SHIP: foreach my $ship (@shipsToAct) { next SHIP if exists($shipsAlreadyDone{$ship}); $shipsAlreadyDone{$ship} = "yes"; #... #Simulated mayhem #... }