For Programmers: Free Programming Magazines  


Home > Archive > PERL Modules > February 2007 > Module namespace: Tie::Flatfile::Array









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Module namespace: Tie::Flatfile::Array
Mumia W.

2007-02-26, 3:59 am


I'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

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com