I've tried to make this work. I added the implied while loop and put brackets around the 'a' etc. to make it generate lists not strings, but I still can get it to produce the same results as the original. Can you see what I missed?
sub belg4mit {
my %H;
my ($len, @k) = @_;
my ($a,$b,$c) = (0)x3;
while($len--) {
$H{(('a')x4,('b')x4,('c')x3)[$len]}
+= $k[$len -1] << (8* ( ($len > 8 ? $len : $len - 1 )%4 )
+);
}
return ($H{a}||0)+($H{b}||0)+($H{c}||0);
}
Examine what is said, not who speaks.
The 7th Rule of perl club is -- pearl clubs are easily damaged. Use a diamond club instead. |