>>>>> "BL" == Ben Lavery <ben.lav...@gmail.com> writes:
BL> use warnings; BL> use strict; good! BL> use Math::Combinatorics; BL> #Read list of valid words into hash BL> my $WORDFILE='Words'; BL> open(WORDFILE, "$WORDFILE") or die "can't open $WORDFILE: $!"; BL> while (<WORDFILE>) { BL> chomp; BL> $word_list{$_} = 0; BL> } BL> close(WORDFILE); don't use glob filehandles. use lexical file handles. or this is even easier and faster: use File::Slurp ; my %word_list = map { chomp; ( $_ => 1 ) } read_file( $WORDFILE ) ; done! BL> #Here, using a hash looks much cleaner than iterating through an array hashes are almost always better for token lookups than scanning arrays. don't doubt yourself in this area. BL> push(@all_combinations, $temp_word) if (exists $word_list{$temp_word}); BL> #Remove duplicates BL> my %hash = BL> @all_combinations = keys %hash; you can merge those: my @all_combinations = keys %{ map { $_ => 1 } @all_combinations } ; uri -- Uri Guttman ------ u...@stemsystems.com -------- http://www.sysarch.com -- ----- Perl Code Review , Architecture, Development, Training, Support ------ --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com --------- -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/