in reply to Play and win the word morph game with the help of Perl :)
1) In the transform sub you copy the contents of the @words array unnecessarily. Change:
To:50 my @words = @{+shift}; 72 foreach my $word (@words) { 95 foreach my $word (@words) {
2) The four argument form of substr is more efficient then assigning to the three argument form of substr. Change:50 my $words = shift; 72 foreach my $word (@$words) { 95 foreach my $word (@$words) {
To:118 substr((my $pat = $word), $i, 1) = '.';
118 substr my $pat = $word, $i, 1, '.';
HTH
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Play and win the word morph game with the help of Perl :)
by Ieronim (Friar) on Jun 29, 2006 at 11:11 UTC |