#!/usr/local/bin/perl


@data = rand_ints( 10, 4, 8 ) ;

print "@data\n" ;


@data = rand_padded_ints( 10, 4, 8 ) ;

print "@data\n" ;

@data = rand_deal( 10, 4 .. 8 ) ;

print "@data\n" ;


@data = rand_deal( 10, 'aa0' .. 'zz9' ) ;

print "@data\n" ;

@data = rand_picks( 10, 'aa0' ) ;

print "@data\n" ;



sub rand_picks {

	my( $count, $pattern ) = @_ ;

	my( @rand, @chars, $char, $pick, @digits, @alphas ) ;

	@chars = split( '', $pattern ) ;

	@digits = ( '0' .. '9' ) ;
	@alphas = ( 'a' .. 'z', 'A' .. 'Z' ) ;

	while( $count-- ) {

		$pick = '' ;

		foreach $char ( @chars ) {

			if ( $char eq 'a' ) {

				$pick .= $alphas[ rand 52 ] ;
				next ;
			}

			if ( $char eq '0' ) {

				$pick .= $digits[ rand 10 ] ;
				next ;
			}
		}

		push( @rand, $pick ) ;
	}

	@rand ;
}

sub rand_deal {

	my( $count, @deck ) = @_ ;

	my( @rand ) ;

	push( @rand, $deck[ rand( @deck ) ] ) while $count-- ;

	@rand ;
}



sub rand_ints {

	my( $count, $base, $range ) = @_ ;

	my( @rand ) ;

	push( @rand, int( rand( $range ) + $base ) ) while $count-- ;

	@rand ;
}



sub rand_padded_ints {

	my( $count, $base, $range ) = @_ ;

	my( @rand, $pad ) ;

	$pad = length( $base + $range ) ;

	push( @rand, sprintf( "%0${pad}d", int( rand( $range ) + $base ) ) )
							while $count-- ;

	@rand ;
}





#splice( @data, int( rand( @data + 1 ) ), 0, $base++ ) while $cnt-- ;

#print "@data\n" ;
