Heres a code snippet which could help you a bit ...
didnt use it for a long time, but AFAIR it works and returns all possible permutations for the given string.
sub DoPermuteArray {
my @array = @{ $_[0] };
my @permuted;
eval (&PermuteArray(['1','1','1','1','-','--'],[],\@permuted));
return @permuted;
}
sub PermuteArray {
# taken from the perl FAQ
my @items = @{ $_[0] };
my @perms = @{ $_[1] };
my $permuted = $_[2];
my @return;
unless (@items) {
push (@$permuted,[@perms]);
} else {
my(@newitems,@newperms,$i);
foreach $i (0 .. $#items) {
@newitems = @items;
@newperms = @perms;
unshift(@newperms, splice(@newitems, $i, 1));
&PermuteArray ([@newitems], [@newperms]);
}
}
}
Rgds.
Gnork
cat /dev/world | perl -e "(/(^.*? \?) 42\!/) && (print $1))"
errors->(c)
|