in reply to Play and win the word morph game with the help of Perl :)

Here are a couple of minor optimisations:

1)  In the transform sub you copy the contents of the @words array unnecessarily. Change:

50 my @words = @{+shift}; 72 foreach my $word (@words) { 95 foreach my $word (@words) {
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:
118 substr((my $pat = $word), $i, 1) = '.';
To:
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
    (2) accepted, (1) - not accepted.

    (1) makes no measurable differece of speed, as the array is copied only once; i left my variant because it simply looks cleaner for me :)