use warnings; use strict; use Spreadsheet::WriteExcel; my @model = qw(x a b c d); my @devicesPerVariant = qw(x 2 1 3 1); my $rowCounter = 1; my $devicePerModel = 2; my $workbook = Spreadsheet::WriteExcel->new("test.xls"); my $worksheet = $workbook->add_worksheet(); my $j = 1; #Declare Headings for row 0 and the 6 Columns $worksheet->write(0,0 , 'Equipment Model'); $worksheet->write(0,1, 'Devices Per Model'); #Loop through Global Array called Models to determine the number of rows to place data for (my $j = 1; $j <= $#model; $j++) { print "row is $rowCounter, $model[$j], $devicesPerVariant[$j]\n"; $worksheet->write($rowCounter,0, $model[$j]); if ($j == 0) { $worksheet->write($rowCounter,1, $devicePerModel); } $worksheet->write($rowCounter,2, $devicesPerVariant[$j]); $rowCounter++; } $workbook->close();