in reply to Parsing a print file

I got bored and wrote something that'll parse your data and even figure out the format on-the-fly. Just be sure no headings have spaces in them. Leading and/or trailing whitespace in each field is left intact, so you'll have to trim that on your own if you need to. (Note that I've expanded upon this code here: Parse fixed-length ascii table)
use Data::Dumper; my (@keys, $format, @data, @sizes); $_ = <DATA>; while (/\G(\S+)\s+/g) { push(@keys, $1); push(@sizes, $+[0]-$-[0]); } $format = join("", map { "a$_" } @sizes); while (<DATA>) { # if you want a hashref for each line: my $i; push(@data, { map { ($keys[$i++], $_) } unpack($format, $_) } ); # else, take out references to @keys above and just use this: push(@data, [ unpack($format, $_) ] ); } print Dumper(\@data); __DATA__ Name ID PS Gender Age Month Code + Cap Pool LName, FName 99999 99 M 99.9 12/2000 Add + 99.99 99.99
Have fun.