in reply to finding and deleting an element from array

The usual way is to do Fisher-Yates shuffle on @cards and deal from the top with pop.

If you wish to pull from a deck with rand, splice is nice.

After Compline,
Zaxo

  • Comment on Re: finding and deleting an element from array

Replies are listed 'Best First'.
Re: Re: finding and deleting an element from array
by bart (Canon) on Sep 05, 2003 at 17:54 UTC
    I'll fill in the blanks, for Zaxo's suggestion to use splice:
    push @hand, splice @cards, int rand @cards, 1;
    You can do this as many times as you wish, to get a full hand.
Re: Re: finding and deleting an element from array
by skaba9 (Beadle) on Sep 05, 2003 at 15:09 UTC
    Gotcha, guess I was doing it backwards.

    Thanks for the replies.