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; }
|
---|
Replies are listed 'Best First'. | |
---|---|
(bbq) RE: Re: Another flatfile thingy
by BBQ (Curate) on Aug 04, 2000 at 17:47 UTC | |
by perlmonkey (Hermit) on Aug 04, 2000 at 20:44 UTC | |
by BBQ (Curate) on Aug 04, 2000 at 21:12 UTC | |
by btrott (Parson) on Aug 05, 2000 at 00:17 UTC |
In Section
Seekers of Perl Wisdom