--- fudge5 2012-10-08 02:21:55.468750000 -0700 +++ fudge6 2012-10-08 01:27:35.187500000 -0700 @@ -80,83 +80,52 @@ push @legal, \$firstCol; push @prod, \$firstCol; - #Gets region from column 2 - if ( my \$val = eval { \$Sheet->Cells( \$row, 4 )->{Value} } ) { - - push @right, \$val; - push @legal, \$val; - push @prod, \$val; - } - - #Gets column 3 information - if ( my \$val = eval { \$Sheet->Cells( \$row, 5 )->{Value} } ) { - - push @right, \$val; - push @legal, \$val; - push @prod, \$val; - } - - #Get the description that needs to be processed later - if ( my \$val = eval { \$Sheet->Cells( \$row, 6 )->{Value} } ) { - - push @legal, \$val; - } - - #Gets area - if ( my \$val = eval { \$Sheet->Cells( \$row, 7 )->{Value} } ) { - - push @right, \$val; - - } - - #Gets column 8 information - if ( my \$val = eval { \$Sheet->Cells( \$row, 8 )->{Value} } ) { - - push @right, \$val; - } - - #Gets column 9 - if ( my \$val = eval { \$Sheet->Cells( \$row, 9 )->{Value} } ) { - - push @right, \$val; - } - - #and so on.... - if ( my \$val = eval { \$Sheet->Cells( \$row, 10 )->{Value} } ) { - - push @right, \$val; - push @legal, \$val; - } - - #same - if ( my \$val = eval { \$Sheet->Cells( \$row, 11 )->{Value} } ) { - - push @right, \$val; - push @legal, \$val; - } - - #same - if ( my \$val = eval { \$Sheet->Cells( \$row, 12 )->{Value} } ) { - - push @right, \$val; - push @prod, \$val; - } - - - for my \$col ( - qw{ + ValueTargetCols( + \$Sheet, + [ \@right, \@legal, \@prod, ], + [ \$row ], + [ qw{ 4 5 } ], + ); + + ValueTargetCols( + \$Sheet, + [ \@legal, ], + [ \$row ], + [ qw{ 6 } ], + ); + + ValueTargetCols( + \$Sheet, + [ \@right, ], + [ \$row ], + [ qw{ 7 8 9 } ], + ); + + ValueTargetCols( + \$Sheet, + [ \@right, \@legal, ], + [ \$row ], + [ qw{ 10 11 } ], + ); + + ValueTargetCols( + \$Sheet, + [ \@prod, \@right, ], + [ \$row ], + [ qw{ 12 } ], + ); + + ValueTargetCols( + \$Sheet, + [ \@prod ], + [ \$row ], + [ qw{ 13 14 15 17 18 20 21 22 23 24 25 26 27 32 33 34 35 36 37 38 39 - } - ) - { - if ( my \$val = eval { \$Sheet->Cells( \$row, \$col )->{Value} } ) { - push @prod, \$val; - } - } - + } ], + ); } } @@ -377,4 +346,20 @@ + +sub ValueTargetCols { + my( \$sheet, \$targets, \$row, \$cols ) = @_; + for my \$col ( @\$cols ) + { + for my \$row( @\$rows ) + { + if ( my \$val = eval { \$sheet->Cells( \$row, \$col )->{Value} } ) { + for my \$target ( @\$targets ){ + push @{\$target}, \$val; + } + } + } + } + return; +} __END__