http://qs1969.pair.com?node_id=26146


in reply to Another flatfile thingy

Well here is another rather sick way to do it if you want to keep the funky data structure you got. Note: I am not saying this is better or faster, just ugly and sort of fun
sub OpenFF { my ($file,$dlmt) = @_; $dlmt = $_[1] || "\t"; my(%hash,%row); open(READ,$file) or return; my @headers = split /$dlmt/, <READ>; s/^\s+|\s+$//g for @headers; chomp(@row{@headers} = split /$dlmt/, <READ>) and %hash = map { $_=>{ $hash{$_} ? %{$hash{$_}} : (), $row{$heade +rs[0]}=>$row{$_}} } @headers while !eof(READ); return %hash; }