in reply to Increasing the efficiency of the code

For a start take the two sorts on invariant hashes (%conwithposition and %cols_pos) outside the main loop. Perform the sorts once each and assign the results to arrays.

You should use strict; use warnings;. It looks like push @listcols, $cols_pos{$col}; is bogus: $col is not defined at that point unless it has been set elsewhere in the program. The $col used as a loop variable in the preceeding foreach is not the same $col used as a key.

A small amount of data and sample contents for the hashes may help evaluate the benefits of other alterations to the code. In this case a little bench marking may help, but code that won't run can't be bench marked.


DWIM is Perl's answer to Gödel