#! /usr/bin/perl use warnings; use strict; use Text::Table; my $t = 'Text::Table'->new; while () { my @cols = split; $t->add(("") x (3 == @cols), @cols); } print $t;