package main; my $cards = LuckyDraw->new(1..52); for (1..5) { my $card = <$cards>; print name_card($card),$/; } my $alltrue = LuckyDraw->new(qw/foo bar baz/); print 'All True:', $/; print while <$alltrue>; print $/; my $onezero = LuckyDraw->new(0..9); print 'One Zero:', $/; print while <$onezero>; print $/; my $onefalse = LuckyDraw->new(0..9); print 'One False:', $/; $_+=0, print while <$onefalse>; print $/; my $onenil = LuckyDraw->new(undef,1..9); print 'One Undef:', $/; print while <$onenil>; print $/; print 'continuing...',$/; print while <$onenil>; print $/; my $shuffle = new LuckyDraw(1..52); print name_card($_),' ' for <$shuffle>; print $/; sub name_card { my $card = shift; sprintf "%s of %s", (qw/Ace Deuce Trey Four Five Six Seven Eight Nine Ten Jack Queen King/)[$card % 13], (qw/Clubs Diamonds Hearts Spades/)[$card / 13]; }