in reply to Clean Up MySQL Code
If you want to write it as a subroutine, this would work:my $results = $dbh->selectall_arrayref( "SELECT * FROM shop_items", { Slice => {} } ); foreach my $hash_ref (@$results) { # blah }
Then you could call it like this:sub fetch_data { my $dbh = shift; return $dbh->selectall_arrayref( "SELECT * FROM shop_items", { Slice => {} } ); }
foreach my $hash_ref (@{&fetch_data($dbh)}) { # blah }
-Matt
|
|---|