Tie::Pick

Randomly pick (and remove) an element from a set
Download

Tie::Pick Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Abigail
  • Publisher web site:
  • http://search.cpan.org/~abigail/

Tie::Pick Tags


Tie::Pick Description

Randomly pick (and remove) an element from a set Tie::Pick is a Perl module that lets you randomly pick an element from a set, and have that element removed from the set.The set to pick from is given as an list of extra parameters on tieing the scalar. If the set is exhausted, the scalar will have the undefined value. A new set to pick from can be given by assigning a reference to an array of the values of the set to the scalar.The algorithm used for picking values of the set is a variant of the Fisher-Yates algorithm, as discussed in Knuth . It was first published by Fisher and Yates , and later by Durstenfeld . The difference is that we only perform one iteration on each look up.If you want to pick elements from a set, without removing the element after picking it, see the Tie::Select module.SYNOPSIS use Tie::Pick; tie my $beatle => Tie::Pick => qw /Paul Ringo George John/; print "My favourite beatles are $beatle and $beatle. "; # Prints: My favourite beatles are John and Ringo. Requirements: · Perl


Tie::Pick Related Software