At no point do you store the value returned by
$sth->fetchrow_arrayref() - your code can be modified to work by changing your code to read
while ($_ = $sth->fetchrow_arrayref()). Please read
DBI for proper syntax and
perlvar for proper usage of
$_. And as
romandas said, please be more contentious formatting your posts.