use strict; use warnings; use Math::BaseArith; my $max_length = 8; for(my $i = 0; $i < 95**$max_length; $i++) { my @base; if ($i) { #can't take log(0) @base = ("95") x (int((log $i) / (log 95))+1); } else { @base = ("95") x (int((log 1) / (log 95))+1); } my $num = encode($i, \@base); my $password = join('', map {chr($_+32)} @$num); }