my @newdeck= shuffle(@starting_deck); sub shuffle { my @cards= @_; foreach (1...30) { my @cut= pop(@cards), shift (@cards), pop(@cards) ... ... push @cards, @cut; } ... return @˘ards; } #### use Data::Dumper; # <-better put this at the beginning of your script, but works here too print Dumper(\@starting_deck);