use strict; use warnings; my $records_wanted = 10; my $minlength=3; my $maxlength=6; # max length of the record - will be specified by user my @alphabet = ( 'a' .. 'z', 'A' .. 'Z', '0' .. '9' ); my $records_made = 0; while ( $records_made++ < $records_wanted ) { my $record = ''; my $record_length = $minlength + int rand( $maxlength - $minlength + 1 ); warn "rlength: $record_length\n"; while ( length $record < $record_length ) { $record .= $alphabet[ rand @alphabet ]; } warn "record: $record\n"; }