# written by norikosama < norikosama@gmail.com >

package Bingo;

use strict;
use base qw(Class::Accessor);
__PACKAGE__->follow_best_practice;
Bingo->mk_accessors(qw(bingo from to count));

sub new{
    my $pkg = shift;
    my $param = shift;
    my $from = 1;
    my $to = 25;
    my $count = 25;
    if(defined($param->{from})){
	if($param->{from}=~/^[0-9]+$/){
	    $from = $param->{from};
	}
    }
    if(defined($param->{to})){
	if($param->{to}=~/^[0-9]+$/){
	    $to = $param->{to};
	}
    }
    if(defined($param->{count})){
	if($param->{count}=~/^[0-9]+$/){
	    $count = $param->{count};
	}
    }
   
    my @array = ($from..$to);
    my @bingo;
    for(($from)..($count)){
	my $num = int(rand(($to)-$_))-1;
	push (@bingo , $array[$num]);
	splice (@array, $num,1);
    }
    
    my $self = {
	from  => $from,
	to    => $to,
	count => $count,
	bingo => \@bingo,
    };
    return bless($self, $pkg);
}
1;
__END__

usage:

use strict;
use Bingo;
my $bingo_array_ref_25 = Bingo->new()->get_bingo;
my $bingo_array_ref_99 = Bingo->new({from=>1 , to=>99 , count =>24 })->get_bingo;
