my $retrieve_ref = $sbh->fetchall_arrayref; for (my $count = 0; $count < @$retrieve_ref; $count++) { $sheet->Range("A$count:B$count")->{Value} = $$retrieve_ref[$count]; }