in reply to Re^2: Equation - code review
in thread Equation - code review

Before you start optimizing your code I recommend writing a test suite that verifies the current behaviour. That way when you introduce errors during optimization they will be easier to spot. You have done the manual verification, put that in a test script.

For example you could do this (and leave alpha_index as it is):

#!c:\perl\bin\perl use strict; use warnings; use Math::BigInt; use Data::Dumper; use Test::More qw(no_plan); my %index_val = ( A => 2, C => 3, D => 4, N => 2, M => 2, T => 1, G => 4); my $sequence = "ACTGACN"; my $distance_index = 3; my $window = 2; my $arr_ref = alpha_index({ sequence => $sequence, distance => $distance_index, aa_index => \%index_val, window_size => $window }); ok($arr_ref); diag("Testing alpha_index with window: $window, distance: $distance_in +dex, sequence: $sequence"); is(ref($arr_ref),'ARRAY','alpha index returned an array'); is(@$arr_ref,7,'7 entries are in the array'); is($arr_ref->[0]{A},2.51025682971601);
Take a look at Test::More for other ideas on what you can test.