This may be what you want:
which prints the data this way:use strict; use warnings; use Data::Dumper; my $file = "1.00 InDev 01-Jun-2013 1.00 InTest 15-Jul-2013 1.00 InUAT 31-Jul-2013 1.00 InProd 15-Sep-2013 1.01 InDev 01-Jul-2013 2.00 InDev 01-Aug-2013 3.00 InDev 01-Sep-2013"; my @file_content = split( /\n/, $file ); my @full_data; for my $line (@file_content) { my @fields = split /\s+/, $line; push @full_data, \@fields; } print Dumper \@full_data;
$ perl table.pl $VAR1 = [ [ '1.00', 'InDev', '01-Jun-2013' ], [ '1.00', 'InTest', '15-Jul-2013' ], [ '1.00', 'InUAT', '31-Jul-2013' ], [ '1.00', 'InProd', '15-Sep-2013' ], [ '1.01', 'InDev', '01-Jul-2013' ], [ '2.00', 'InDev', '01-Aug-2013' ], [ '3.00', 'InDev', '01-Sep-2013' ] ];
The four important lines:
could be made much more concise:for my $line (@file_content) { my @fields = split /\s+/, $line; push @full_data, \@fields; }
but I preferred to keep a step by step approach to make understanding easier.push @full_data, [split] for @file_content;
Update:: when I posted the above, Deep_Plaid had not updated the original post with the addition of the desired output. As I said in another post above, it may not be necessary to build this AoA to arrived at the desired output. The solution might be much simpler.
In reply to Re: Dynamically build a table
by Laurent_R
in thread Dynamically build a table
by Deep_Plaid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |