use Math::BaseArith; my $base = 4; #Start with 2 digits of precision my $prec = [$base, $base]; for my $i (2..3) { my $max = ($base ** $i); PREC: for my $line (0..4**$i) { last PREC if ($line >= $max ); #Check for overflow print encode( $line, $prec), "\n"; } push @{$prec}, $base; #+Another digit of precision. }