RE: generating a wordlist from an array of arrays



Mark,

I like to use glob for such tasks.

perldoc -f glob
perldoc File::Glob
bash-2.05b$ perl -le 'print for glob ("{a,b}{c}{d,e,f}")'
acd
ace
acf
bcd
bce
bcf

Regards,
Scott

PS: I apologize for the top post.

-----Original Message-----
From: mark berger [mailto:mb@xxxxxxxxxxx]
Sent: Thursday, September 29, 2005 1:27 PM
To: beginners@xxxxxxxx
Subject: generating a wordlist from an array of arrays

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

the only thing i came up with so far, is to generate some for loops
based on the array structure (how many chars, with how many posible
values) on fly and pass this to eval. pretty ugly (at least the way i
thought it out).

any hints on how to solve this? probably using recursion but i got no
idea about it right now. and sorry for my bad english, hope i can make
my problem understandable.

--
To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
For additional commands, e-mail: beginners-help@xxxxxxxx
<http://learn.perl.org/> <http://learn.perl.org/first-response>


.



Relevant Pages

  • Re: Currency Rounding Errors
    ... If you want to stop at that precision. ... What I did was my own Number class, that stored the digits in an array, ... The x86 is the first machine in history to waste 5 of the bits of the byte to create BCD. ... bytes and do weird instructions such as ADD followed by AAA, ...
    (microsoft.public.vc.mfc)
  • Re: Currency Rounding Errors
    ... If you want to stop at that precision. ... What I did was my own Number class, that stored the digits in an array, ... So BCD was not enough. ... There's a whole bunch of such funny instructions such as ...
    (microsoft.public.vc.mfc)
  • Re: BCD-Decimal
    ... How is your BCD number held, as a byte array or what? ... How do you want the decimal equivalent, as a string, int, long, double ...
    (microsoft.public.dotnet.languages.csharp)