use strict; my $counter = 0; my $randstring; my @testarray = ( 'a' .. 'z', 'A' .. 'Z', '0' .. '999' ); do { $randstring .= splice(@testarray, int rand @testarray, 1); ++$counter; } until $counter == 1051; print "$randstring\n";