If I understand you correctly then all that code is just to avoid printing numbers that have more than eight zeroes
You can do that like this
my $credit_card_number = "$a$b$c$d$e$Fc$g$h$i$j$k$l$m$n$o$p";
print $credit_card_number, "\n" unless $credit_card_number =~ tr/0// > 8;
But I still think your enterprise is a fruitless one
solved Generateing all possible 16 digit number requireling less storage location