[Israel.pm] tie

Itamar Elem elem at compugen.co.il
Tue Jun 15 07:38:47 PDT 2004


hi shlomo

i think you can do something like the mldbm does

when you assign value to one of the toplevel array cells
you packed the value with storable and mabye with compress something like  compress freeze $value (inside the tie package )
and when you fetch the value in the tie package you do the opposite  thaw uncompress  $value

i think than you can do something like $v[$i][$j] in your main module

itamar

-----Original Message-----
From: Shlomo Yona [mailto:shlomo at cs.haifa.ac.il]
Sent: Tuesday, June 15, 2004 5:18 PM
To: perl at perl.org.il
Subject: [Israel.pm] tie


Hello,

I have a list of lists (LoL), which is a list of binary
vectors.

.1.

I'd like to have this list of vectos tied to a file.
That's easy:

	tie @list_of_vectors, 'Tie::File', $vectors_list_filename;

BUT -- the vectors themselves must now be represented as
strings... and I cannot look up in them, I cannot do
operations on them unless I split the "line" before usage
and then join the "vector" back to a "line" after doing my
stuff.

I wonder if there's a way to allow a LoL to be tied nicely
to a file, so that the usage is just like using a LoL but in
fact the data is tied to a file, rather than being all in
memory.

.2.

To make things more complicated: What if I wanted to have
the vectors be sparse-vectors, but still keep the simple LoL
usage instead of all the extra hassle which is now required
to handle the tied list and the sparse vector.....?



Are there ready made solutions for this? How?



-- 
Shlomo Yona
shlomo at cs.haifa.ac.il
http://cs.haifa.ac.il/~shlomo/
_______________________________________________
Perl mailing list
Perl at perl.org.il
http://perl.org.il/mailman/listinfo/perl




More information about the Perl mailing list