#!/usr/bin/perl my $str = "cat"; for (reverse 0..(length($str)-1)) { substr($str,$_,1) x= rand(9)+1; } print "$str\n";