in reply to Re^2: Moving from SQL to flat-files
in thread Moving from SQL to flat-files
Before you come up with yet another metadata syntax, you might want to look at LDIF, which your syntax looks similar to.
But as for reading the data / metadata, it's not too hard:
my @data = (); while ( my $line = <IN>) { last if ($line =~ /^__METADATA__$/); push @data, $line; } # assuming no multivalue keys my %metadata = map { chomp $_; split( $_, /:/, 2) } (<IN>);
I'd personally put the metadata before the data -- as there's no chance in the marker being in the metadata section, but there is in the data. I don't know what your usage patterns are, so it might be an additional overhead to be skipping the metadata whenever it's not needed, though:
while (my $line = <IN>) { last if ($line =~ /^__DATA__$/); } my @data = <IN>;
I'd also avoid hashing on titles / names if the data is going to grow significantly, and the title isn't the only indexor. The english language just doesn't have good distribution.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Moving from SQL to flat-files
by punkish (Priest) on May 09, 2006 at 17:01 UTC |