$header{'Number of Drills'} = (map { $total += $_->{count} foreach (values %{ $_->{tool} }); $total } @drill_arr)[-1];