in reply to pushing onto array is not working as intended..

Your output looks like a hash or list was pushed on the array instead of a hash reference. Sure enough, the first if has:

push @{$records}, %record;
instead of
push @{$records}, \%record;

Note the missing backslash.

G. Wade