in reply to Re^2: Dynamically build a table
in thread Dynamically build a table

Hi, is this what you are looking for:

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; push @full_data, [split] for @file_content; for my $line_ref (@full_data) { print "$_\t" for @$line_ref; print "\n"; }
This is the output:
$ perl table.pl 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

Update Mar 11, 19:45 UTC: Looking again at the OP and at another answer you made which I had not seen, I think I now understand what you are trying to do (and the above is not what you need). You're basically wanting to do a form of transposition of the data, where, in part, what you have in row form should not appear in columns, and vice-versa, although it is not a simple matrix transposition. I don't have time right now (I'm gonna have dinner with my family right now), but I think I can come back to it in a couple of hours unless someone else does it before me.

Replies are listed 'Best First'.
Re^4: Dynamically build a table
by Laurent_R (Canon) on Mar 11, 2014 at 22:06 UTC
    Now that what you really wanted is clear to me, I agree with 2teez that a hash of hashes is probably a better solution than the AoA one I suggested originally to represent your data not knowing what you wanted to do with it. I had warned in my first post that another data structure might be better, depending on what you intended to do with the data (which was not known at the time). And the very nice solution offered by Cristoforo seems to fit exactly what you need. So, although it would be perfectly possible to generate the same type of output with an AoA, there is no point for me to continue that route. Happy to help if you have any further questions.