I'm curious. What version of MySQL and DBI are you using? I haven't seen the methods you are using before: selectall_arrayref I use fetchall_arrayref. And, an array ref should be assigned to a $variable not an @variable. It is a reference to an array not a real array.
i am using mysql 4.0.17 max-debug and DBI 1.38. i am just using USE:DBI. I realised the thing you said about arrayrefs and changed it , but the problem still remains with the loops.