This might be a possible solution
#!/usr/bin/perl -w
use strict;
my $hint = '1234';
my @chars = ('0'..'9', 'a'..'z');
my $len = 6 - length $hint;
&append ("");
sub append {
my $s = shift;
if (length $s >= $len) {
&hint($s);
return;
}
foreach (@chars) {
my $new = $s.$_;
&append ($new);
}
}
sub hint {
my $s = shift;
my $new;
for (my $i=0; $i<=length($s); ++$i) {
$s =~ m/^(.{$i})(.*)$/;
$new = $1.$hint.$2;
print $new."\n";
}
}
But for larger password sizes, this could fill the call stack, so, as long as
you know the exact length of the password, you could get rid of the recursion by hardcoding nested foreach()-loops instead.
My first idea, how to do it with flexible password sizes
and without recursion, would be to write a code generator
that nests the necessary number of foreach()-loops for you,
using the password size as a parameter.
Maybe this is too complicated but the only thing that
comes to my mind at the moment.
| [reply] [d/l] |