in reply to Creating random generated data...

I'd probably rewrite this way:

use strict; use warnings; my $records_wanted = 10; my $minlength=3; my $maxlength=6; # max length of the record - will be specified by use +r 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"; }

A few notes...

Sample output:

rlength: 4 record: 3J9J rlength: 5 record: 9NxuW rlength: 5 record: rwtwj rlength: 3 record: AVY rlength: 3 record: WPY rlength: 5 record: wxeTn rlength: 5 record: 86JH1 rlength: 6 record: PwLx2X rlength: 4 record: nXuG rlength: 4 record: cpXk

Replies are listed 'Best First'.
Re^2: Creating random generated data...
by perl_junkie (Acolyte) on Mar 25, 2008 at 17:49 UTC
    Thanks Ikegami, Kyle....!!! This really helps.

    Kyle, I have noted your comments and will keep them in mind.... I have only been doing this for a month and the inexperience probably shows..!! :)