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.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.