Re: generating a wordlist from an array of arrays
- From: jag.robin18@xxxxxxxxxx (Gerard Robin)
- Date: Fri, 30 Sep 2005 01:18:31 +0200
On Thu, Sep 29, 2005 at 07:26:51PM +0200 mark berger wrote:
> hey list. i stuck with gererating a wordlist from a changing
> multidimensional array. each entry in the array contains a list with the
> possible values.
>
> fe:
>
> @wordlayout = ((a, b), # possible values for 1st char
> (c), # possible values for 2nd char
> (d, e, f)); # possible values for 3rd char
>
> the following wordlist should be generated:
>
> acd
> ace
> acf
> bcd
> bce
> bcf
use references for multidimensional arrays:
#!/usr/bin/perl
use warnings;
@w1 = (["a", "b"], ["c"], ["d", "e", "f"]);
$str ="";
foreach $k (@{$w1[0]}) {
foreach $l (@{$w1[2]}) {
$str = $str.$k.@{$w1[1]}[0].$l." ";
}
}
@w2 = split " ", $str;
foreach (@w2) {
print "$_\n";
}
it's another solution ...
hth
--
Gérard
.
- References:
- generating a wordlist from an array of arrays
- From: Mark Berger
- generating a wordlist from an array of arrays
- Prev by Date: RE: a little help...
- Next by Date: RE: a little help...
- Previous by thread: Re: generating a wordlist from an array of arrays
- Next by thread: Re: generating a wordlist from an array of arrays
- Index(es):
Relevant Pages
|