If you have the luxury to use Data::Random then use that by all means. But if that is not available (for example in production environment), here is another way to create some random data.
sub generate_random_data
{
my $passwordsize = shift;
my @alphanumeric = ('a'..'z', 'A'..'Z', 0..9);
my $randpassword = join '',
map $alphanumeric[rand @alphanumeric], 0..$passwordsize;
return $randpassword;
}