our @common_letters = (); our @wordsCopy = @words;
should be
local our @common_letters; local our @wordsCopy = @words;
Calling subroutines is expensive. I'd try replacing
local our @common_letters; local our @wordsCopy = @words; my $reference = shift @wordsCopy; $reference =~ /(.)(?{ ... })/gx;
with
my @common_letters; my @wordsCopy = @words; my $reference = shift @wordsCopy; while ($reference =~ /(.)/g) { ... }
There's also
for my $c($reference =~ /./g) # uses $c instead of $1
and
for my $c (split(//, $reference)) # uses $c instead of $1
The "() =" is useless.
What's with the use of $bolean? Aside from the fact that it should be spelled "boolean",
can be written as
Seems to me
my @wordsCopy = @words; my $reference = shift @wordsCopy;
is a roundabout way of doing
my ($reference, @wordsCopy) = @words;
It might be faster to split the words into arrays at the top of the function then using array lookups instead of substr.
for ( @splitWord ) { if ( $_->[$position] ne $letter ) { $bolean = 0; last } }
In reply to Re: Strange "undefined value as an ARRAY reference" error
by ikegami
in thread Strange "undefined value as an ARRAY reference" error
by johngg
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |