in reply to creating word from array of array
This prints:#!/usr/bin/perl -w use strict; # Set up my @charsets = ( [ "b", "h" ], [ "e" ], [ "l", "p", "i" ], [ "l" ], [ "o" ], ); # Do it my @words = (""); for my $char_ref (@charsets) { my @temp_words; for my $word_part (@words) { for my $char (@$char_ref) { push @temp_words, $word_part . $char; } } @words = @temp_words; } # Show it print "$_\n" for @words;
------------------------------------------------------------
"Perl is a mess
and that's good because the
problem space is also a mess." - Larry Wall
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: creating word from array of array
by smgfc (Monk) on Feb 17, 2002 at 00:19 UTC |