in reply to push result into array
push tries to add items to its first argument. Your loop is resetting @result each time through. You probably want something like:
while (@result = $sth->fetchrow_array()) { push @dept, @result; } [download]