in reply to Clean Up MySQL Code

You can reduce three of your lines to one by using selectall_arrayref() like so:
my $results = $dbh->selectall_arrayref( "SELECT * FROM shop_items", { Slice => {} } ); foreach my $hash_ref (@$results) { # blah }
If you want to write it as a subroutine, this would work:
sub fetch_data { my $dbh = shift; return $dbh->selectall_arrayref( "SELECT * FROM shop_items", { Slice => {} } ); }
Then you could call it like this:
foreach my $hash_ref (@{&fetch_data($dbh)}) { # blah }

-Matt