perl_junkie has asked for the wisdom of the Perl Monks concerning the following question:
I am working on a random data generation program which accepts the data type and data length as input parameters and then creates random data for this, so that it can be loaded into the tables for testing. I got code pieces from another thread and what I have pasted below gives an alphanumeric output by taking the number of records and the length as inputs. But I am having the hardest time getting a proper alphanumberic output from this if the length of the data and the number of records are given.
Can someone please help me out with this?
Thanks!
#!/usr/bin/perl use Fcntl; #The Module use strict; use Math::Trig; my $count=10; # Number of records required. my $minlength=3; my $maxlength=6; # max length of the record - will be specified by use +r my $rlength; my $cnt=1; while ($cnt <= $count) { my $newvar; my @vchars=('a'..'z','A'..'Z',0..9); $rlength=$minlength+=int(rand($maxlength)); print "rlength is $rlength\n"; while(length($newvar) < $rlength) { my $char=$vchars[int(rand($#vchars))]; $newvar.=$char; } $cnt++ }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Creating random generated data...
by kyle (Abbot) on Mar 25, 2008 at 17:42 UTC | |
by perl_junkie (Acolyte) on Mar 25, 2008 at 17:49 UTC | |
|
Re: Creating random generated data...
by ikegami (Patriarch) on Mar 25, 2008 at 17:27 UTC | |
|
Re: Creating random generated data...
by planetscape (Chancellor) on Mar 25, 2008 at 21:57 UTC |