Welcome to the Monastery | |
PerlMonks |
Manipulating Arraysby webchalkboard (Scribe) |
on Aug 11, 2005 at 11:42 UTC ( [id://482912]=perlquestion: print w/replies, xml ) | Need Help?? |
webchalkboard has asked for the wisdom of the Perl Monks concerning the following question: Hi again, I have a much simplier and cooler question this time, and was wondering the best way to do this. Basically I have an array of words for example ('the','cat','sat','on','the','matt') and I want to create lots of different combinations of these words, so I would like to end up with short two word phrases like 'cat matt' and 'cat sat' or 'matt cat the'. What is the best way of achieving this result? I was thinking about counting the number of items in the array and then connecting random elements together. Most phrases would only be about 4 words long, and if I could get every permutation of these words up to say 50 permutations that would be perfect... i'm sure there is a cool perl way, any suggestions? Many thanks, Learning without thought is labor lost;
thought without learning is perilous. - Confucius
WebChalkboard.com | For the love of art...
Back to
Seekers of Perl Wisdom
|
|