Nath, Alok (STSD) wrote: > > Can anybody help me to simplify the for loops here ? > It parses the excel file. > > > foreach my $col (1..10){ > push @row_1, $Sheet->Cells(1, $col)->{'Value'} ; > } > my @node_names = th([EMAIL PROTECTED]); > > foreach my $col (1..10){ > push @row_2, $Sheet->Cells(2, $col)->{'Value'} ; > } > my @workstations = td([EMAIL PROTECTED]); > > > foreach my $col (1..10){ > push @row_3, $Sheet->Cells(3, $col)->{'Value'} ; > } > my @cards = td([EMAIL PROTECTED]); > > > I am using the above for loops to create a table -finally. > > > print table({-border=>undef,-width=>'100%'}, > caption(b('My table')), > Tr([EMAIL PROTECTED]), > Tr([EMAIL PROTECTED]), > Tr([EMAIL PROTECTED]), > }
Is everybody trying for an obfuscation award here? In your code, Alok, the output from th() and td() is a single piece of HTML text and so doesn't need storing in an array. Instead put the Excel table values into your arrays and build all the HTML at once. Like this. HTH, Rob my (@node_names, @workstations, @cards); foreach my $col (1 .. 10) { push @node_names, $Sheet->Cells(1, $col)->{'Value'}; push @workstations, $Sheet->Cells(2, $col)->{'Value'} ; push @cards, $Sheet->Cells(3, $col)->{'Value'} ; } print table({-border=>undef,-width=>'100%'}, caption(b('My table')), Tr(th([EMAIL PROTECTED])), Tr(td([EMAIL PROTECTED])), Tr(td([EMAIL PROTECTED])), ); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/