my $sql = "SELECT * from shop_items"; my $sth = $dbh->prepare($sql); $sth->execute; while (my $hash_ref = $sth->fetchrow_hashref) { # bla bla bla }