in reply to foreach problem

Keep in mind an array of hashes is actually an array of references to hashes.

$libs[$i]{'file'}

is shorthand for

$libs[$i]->{'file'}

so if you replace array element $libs[$i] with scalar $lib, you get

$lib->{'file'}

$lib{'file'} refers to the hash %lib.