use strict; use warnings; use text::table; use Data::Dumper; sub main { 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"; # This seems to be the only way to convert the scalar file to an array # where each line is an array element. There's probably a better way. my @array = split( /\n/, $file ); # This is simply a test to see what the array looks like print Dumper(@array); }; main(); # This next bit of code is not connected to the above because I don't # know the best way to build a data structure for the table. # Therefore I'm just creating a simple dummy array based on what a # single line of the table might look like. In addition, if there # are no matches with an (x,y) location in the table for a certain # row of data, I would like to fill it with the text "N/A", # hard coded as an illustration below. my @tarray = ( "1.0", "06-Mar-2014", "06-Mar-2014", "06-Mar-2014", "06-Mar-2014" ); my $tb = Text::Table->new( "Module", "Version", "InTest", "InUAT", "INProd" ); $tb->load( [ "Module 1", $tarray[0], $tarray[1], $tarray[2], $tarray[3] ], [ "Module 2", "N/A", "N/A", "N/A", "N/A" ], [ "Module 3", "N/A", "N/A", "N/A", "N/A" ], ); print $tb; #### Module Version InDev InTest InUAT INProd Module 1 1.00 01-Jun-2013 15-Jul-2013 31-Jul-2013 15-Sep-2013 Module 1 1.01 01-Jul-2013 N/A N/A N/A Module 2 2.00 01-Aug-2013 N/A N/A N/A Module 3 3.00 01-Sep-2013 N/A N/A N/A