|Think about Loose Coupling
Be aware that the documentation for DBI specifically forbids using fetchrow_hashref in that way:
Currently, a new hash reference is returned for each row. This will change in the future to return the same hash ref each time, so don't rely on the current behaviour.Although your code will work with existing versions of DBI, in some future version it will break with every reference in the array pointing to the same hash, containing the last row fetched. Instead, you should make sure to create a new hash for each row:
There's also fetchall_arrayref, as lachoy explained.