Hello Monks,
I have a problem with Storable and MLDb... substantially, because I have not confidence with these modules.
I use a mailing list software that I love, but I have a problem with data format.
This software store data not with a RDBM database, but using MLDb and Storable.
I need to create a connector (I can: this software is Open Source) in order to connect it to my personal website, but I'm not able to manipulate data with those two modules.
Ok, I go to the code,
That software use:
use Fcntl qw(
O_WRONLY
O_TRUNC
O_CREAT
O_CREAT
O_RDWR
O_RDONLY
LOCK_EX
LOCK_SH
LOCK_NB);
use MLDBM qw(AnyDBM_File Storable);
and these are some rows, the software use to store data:
my $dbm = tie %{$self->{DB_HASH}}, 'MLDBM', $self->_db_filename, O_CRE
+AT|O_RDWR, FILE_CHMOD
then with that row, it read the file:
sysopen(DB_SCHEDULE_SAFETYLOCK, $self->_lockfile_name, O_RDWR|O_CREAT
+, FILE_CHMOD )
I think these are all the rows involved in data storage.
If you are interesting in, the modules are these ones:
MLDb.pm
Schedules.pm
I need to read the generated files, in order to write or append there some data.
I tried in several way to read that file, but without success.
For example with:
use MLDBM qw(AnyDBM_File Storable);
use Storable qw(retrieve_fd);
use Fcntl qw (:DEFAULT :flock);
use FindBin qw($Bin);
tie (%hash, "MLDBM", $Bin.'mj-test-schedules', O_CREAT|O_RDWR, 0666)
or die $!;
# sysopen(DB_SCHEDULE_SAFETYLOCK, $Bin.'/mj-test-schedules', O_RDW
+R|O_CREAT, 0666);
#open FILE, ">", $Bin.'/filename.txt' or die $!;
open (DF,$Bin.'/mj-test-schedules') or die $!;
flock (DF, LOCK_SH) or die $!;
$href=retrieve_fd(*DF);
close DF;
while ( my ($key, $value) = each(%$href) ) {
print "$key => $value\n";
}
#print FILE $_ while (<DB_SCHEDULE_SAFETYLOCK>) ;
#close FILE;
untie %hash;
In addition I don't understand (and that is probably the problem) what MLDb does and how Storable and MLDb work together.
Please, someone can help me?
Thank you very much.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.