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++ }
In reply to Creating random generated data... by perl_junkie
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |