$output = [ [ [0],[0],[0] ], [ [1,1,1],[1,1,1],[1,1,1] ], [ [2,2,2],[2,2,2],[2,2,2] ], [ [3,3,3],[3,3,3],[3,3,3] ], [ [4,4,4],[4,4,4],[4,4,4] ], [ [5,5,5],[5,5,5],[5,5,5] ], [ [6,6,6],[6,6,6],[6,6,6] ], [ [7,7,7],[7,7,7],[7,7,7] ], [ [8,8,8],[8,8,8],[8,8,8] ], [ [9,9,9],[9,9,9],[9,9,9] ], ]; #...other code that sets up the Excel sheet... my $Book = $Excel->Workbooks->Open("$excelfile"); for $i (1..9) { my $Sheet = $Book->Worksheets("$i"); $Sheet->Range("A1:C3")->{'Value'} = $$output[$i]; } #### open (FILEIN,"$filein") or die "Open $filein failed: $!"; while () { @data = split; push @$output, [@data]; } close FILEIN; #...other code that sets up the Excel sheet... my $Book = $Excel->Workbooks->Open("$excelfile"); my $Sheet = $Book->Worksheets("$sheetname"); # ...other code that determines # $begcol,$begrow,$endcol,endrow $Sheet->Range("$begcol$begrow:$endcol$endrow")->{'Value'} = $output; #### push @$output, [@data]; #### push $$day_output[$data[1]], [@data];