use Math::BaseCalc; $calc4 = new Math::BaseCalc(digits=>[qw/A T C G/]); print($calc4->to_base($_), "\n") for 0 .. 4 ** $L - 1;