in reply to Dynamically build a table

Borrowing from 2teez's solution, the table could be loaded like this.

Update A possible change of code to fit Deep_Plaid's followup question.

#!/usr/bin/perl use strict; use warnings; use Text::Table; 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"; open my $fh, '<', \$file; my %line; while (<$fh>) { my ($ver, $status, $date) = split; $line{ $ver }{ $status } = $date; } my @status = qw/ InDev InTest InUAT InProd /; my @module = (undef, qw/ IXR Reports Three /); my $tb = Text::Table->new( "Module", "Version", @status ); for my $ver (sort keys %line) { my ($i) = $ver =~ /(\d+)/; $tb->load([ $module[$i], $ver, map $_ // 'N/A', @{$line{$ver}}{ @s +tatus } ]); } print $tb;
Produces output:
Module Version InDev InTest InUAT InProd IXR 1.00 01-Jun-2013 15-Jul-2013 31-Jul-2013 15-Sep-2013 IXR 1.01 01-Jul-2013 N/A N/A N/A Reports 2.00 01-Aug-2013 N/A N/A N/A Three 3.00 01-Sep-2013 N/A N/A N/A

Replies are listed 'Best First'.
Re^2: Dynamically build a table
by Deep_Plaid (Acolyte) on Mar 14, 2014 at 15:28 UTC

    Thanks so much Cristoforo! This is great! I knew there had to be a fairly simple way to do this. I will need to step through this to really understand each piece, but I know I will learn a lot. There's only one minor thing missing. I will try to fix it myself, but any hints are appreciated. I need to correspond the module with the first digit of each version number (e.g., if version = 1.xx then "Module 1", if version = 2.xx then "Module 2", etc.). This is really a matching exercise because in real life the module names don't match the version numbers (only in my example). E.g., Module1 is really just a platform name such as IXR, Module 2 is Reports, etc.). Thanks again!