#!/usr/bin/perl -w
use strict;
use Text::Table;
my %data;
while (<>) {
my ( $rep, $product, $foo ) = split ' ';
$data{$rep}{$product} = $foo;
}
my @reps = sort keys %data;
my $table = Text::Table->new( '', @reps );
for my $i ( 0 .. $#reps ) {
my $rep = $reps[$i];
my @products = sort keys %{ $data{$rep} };
foreach (@products) {
$table->add( $_, ('') x $i, $data{$rep}{$_} );
}
}
print $table;
BTW, having never used Text::Table before, I found it surprisingly powerful. Most of that power is unused on this program.