Module namespace: Tie::Flatfile::Array
am 26.02.2007 05:55:19 von paduille.4060.mumia.w+nospamI'm creating a module called Tie::Flatfile::Array. The module will allow
the user to treat a "database" flat-file as an array of arrays. This is
how my new module might be used:
#!/usr/bin/perl
use strict;
use warnings;
use Tie::Flatfile::Array;
use Fcntl;
my $packformat = 'A30N';
tie my @db, 'Tie::Flatfile::Array', 'my.flat',
O_RDWR | O_CREAT, 0644, $packformat
or die("tie failed: $!");
push @db, ['yahoo.com', 3461];
push @db, ['lycos.com', 1449];
push @db, ['search.go.com', 960];
local $" = "\t";
print "@{[ qw(SearchDomain Hits) ]}\n";
for my $ix (0..$#db) {
print "@{$db[$ix]}\n";
}
untie @db;
__END__
The $packformat specifies that each record will contain thirty ascii
characters followed by an integer in network byte-order (A30N). I think
the appropriate namespace for this module is Tie::Flatfile::Array¹. What
do you people think about the namespace and the module?
----------------------
¹ A Tie::Flatfile::Hash may or may not be coming too.
--
Windows Vista and your freedom in conflict:
http://techdirt.com/articles/20061019/102225.shtml