in reply to Improving the Nested For Loop
PDL::Stats::Basic can calculate correlations for you. And it probably does it faster than you do, so give it a try!