in reply to loop in loop method evasion
use strict; use warnings; my @chartab = (0..9, 'a'..'z'); my $depth = 4; print permute(\@chartab,'',$depth); sub permute { my ($chartab_ref, $intro, $depth) = @_; return "$intro," if ($depth == 0); my $string = q{}; foreach my $letter (@$chartab_ref) { $string .= permute($chartab_ref, $intro.$letter,$depth-1); } return $string; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: loop in loop method evasion
by ikegami (Patriarch) on Dec 26, 2009 at 06:34 UTC |