in reply to printing column info without headers

The way you mention columns in some of your responses leads me to believe this is a fixed width table, if not ignore this response. This uses DataExtract::FixedWidth
use DataExtract::FixedWidth; use IO::File; use feature ':5.10'; my $fh = IO::File->new( 'file.txt', 'r' ); my @tuples = <$fh>; my $de = DataExtract::FixedWidth->new({ heuristic => \@tuples }); foreach my $tuple ( @tuples ) { state $row; my $arr = $de->parse( $tuple ); given ( ++$row ) { when ( 1 ) { say $arr->[0] } when ( 2 ) { say $arr->[2] } } }
or
my $de = DataExtract::FixedWidth->new({ heuristic => \@tuples , column_names => [qw/foo bar baz/] }); foreach my $tuple ( @tuples ) { state $row; my $hash = $de->parse_hash( $tuple ); given ( ++$row ) { when ( 1 ) { say $hash->{foo} } when ( 2 ) { say $hash->{baz} } } }


Evan Carroll
I hack for the ladies.
www.EvanCarroll.com