I know that this may not help you with the problem you've posted, but it is something that can become important. Then I'll nitpick one smaller thing.
Your last line of the bar() sub is return %locations, so you are copying the data structure over to the foo() sub. This might take up a few extra cycles if the hash is quite large, so you might want to consider passing by reference instead. Change that last bar() line to return \%locations;, that first line of foo() to my $locations = bar($dbh);, and then dereference $locations to get at the values. My little nitpick is getting rid of the '&' symbol that is part of your call to foo(). Nasty, nasty, nasty (:
C:\>shutdown -s
>> Could not shut down computer:
>> Microsoft is logged in remotely.