THank you all for excellent replies. All of them are working fine and now I am trying to 'decode' each of them :D.
Hi onelesd,
Can you please explain the if (! defined $min{$col2}) part of your code. Ever since you posted this code, I have been banging my head to understand the usage of defined and the unary operator !. Thanks in advance.