Re: Simple multi-level tie

2004-01-07 Thread Martyn J. Pearce
On Tue, Jan 06, 2004 at 01:00:36PM -0600, david nicol wrote: that works too. The first time I worked with dbm files, it was with an implementation that produced both a .pag and a .dir file for a database, so there was no one data file to lock. If I just use Copendbm and let Perl select an

Re: Simple multi-level tie

2004-01-06 Thread A. Pagaltzis
* david nicol [EMAIL PROTECTED] [2004-01-06 20:03]: I'm also safe from the implementation needing the flock bits if it uses them. I don't know that they do, but I also don't know that they don't. You're also safe because tieing and locking is not an atomic operation, and some DBM libraries

Re: Simple multi-level tie

2003-12-22 Thread david nicol
On Fri, 2003-12-19 at 22:26, Terrence Brannon wrote: I quit using DBM files after one corrupted on me during an aborted write. A similar negative experience got me in the habit of being strict with locking discipline when using DBM. open advisory file lock advisory file

Re: Simple multi-level tie

2003-12-19 Thread Andrew Sterling Hanenkamp
Okay, so I ended up having more time last night than I thought I would. I finished Tie::Filter and the filter packages for scalars, arrays, and hashes. I've decided to hold off on writing one for handles as it is a significantly more complicated problem--and it might be better as an IO:: class.

Re: Simple multi-level tie

2003-12-19 Thread Terrence Brannon
Andrew Sterling Hanenkamp wrote: use Storable qw(freeze thaw); use Tie::HashWrapper; tie my %wrappee, 'AnyDBM_File', ...; tie my %hash, 'Tie::HashWrapper', \%wrappee, -inflate_value = sub { thaw(shift) }, -deflate_value = sub { freeze(shift) }; $hash{a}{complicated}[4]{data} = [

Re: Simple multi-level tie

2003-12-18 Thread Tim Bunce
On Wed, Dec 17, 2003 at 02:00:23PM -0600, Andrew Sterling Hanenkamp wrote: I would like the ability to store a complicated record inside of a DBM file. I looked in the usual places and perldoc -q DBM gives me: Either stringify the structure yourself (no fun), or else get the

Re: Simple multi-level tie

2003-12-18 Thread Andrew Sterling Hanenkamp
On Thu, 2003-12-18 at 05:59, A. Pagaltzis wrote: I'd prefer if it didn't (ab)use the minus on literal string. There's nothing ambiguous in the syntax that might require it. I disagree, since the tie call could include -inflate_key and -deflate_value. It is also legal to say: tie %hash,

Re: Simple multi-level tie

2003-12-18 Thread Andrew Sterling Hanenkamp
On Thu, 2003-12-18 at 04:26, Tim Bunce wrote: I'd add a -1 to the split and not in the docs that the example won't handle undefs. Fine. The example is relatively close to what I need the package for, but as a general example it's probably a poor one. I didn't like it at first but the more I

Re: Simple multi-level tie

2003-12-18 Thread Andrew Sterling Hanenkamp
I would like to revise my original query into a proposal in light of the comments I've received to now suggest a Tie::Filter namespace for filtering Tie classes. There could be specialized classes Tie::Filter::Scalar, Tie::Filter::Array, Tie::Filter::Hash, and Tie::Filter::Handle. However, at

Re: Simple multi-level tie

2003-12-18 Thread Andrew Sterling Hanenkamp
Another question I want to add to my proposal is: should the code references work by modifying $_ in-place (as with DBM filters) or should the code take an argument and return a result. I think I lean towards the modification of $_ in-place as it seems a little more Perlesque. Cheers, Sterling

Re: Simple multi-level tie

2003-12-18 Thread Mike Guy
Andrew Sterling Hanenkamp [EMAIL PROTECTED] wrote use Storable qw(freeze thaw); use Tie::HashWrapper; tie my %wrappee, 'AnyDBM_File', ...; tie my %hash, 'Tie::HashWrapper', \%wrappee, -inflate_value = sub { thaw(shift) }, -deflate_value = sub { freeze(shift) }; Or rather more

Re: Simple multi-level tie

2003-12-18 Thread A. Pagaltzis
* Andrew Sterling Hanenkamp [EMAIL PROTECTED] [2003-12-18 20:01]: I think I lean towards the modification of $_ in-place as it seems a little more Perlesque. Given the name Tie::Filter, I'd agree. -- Regards, Aristotle If you can't laugh at yourself, you don't take life seriously enough.

Re: Simple multi-level tie

2003-12-18 Thread A. Pagaltzis
* Andrew Sterling Hanenkamp [EMAIL PROTECTED] [2003-12-18 19:02]: However, at this point, this project is becoming far more serious than the original idea Which is always good when code's meant to go onto CPAN :-) The wrapped object must be of the same type as the tie itself since the

Re: Simple multi-level tie

2003-12-18 Thread Andrew Sterling Hanenkamp
On Thu, 2003-12-18 at 14:11, A. Pagaltzis wrote: I do, because for simple one-off uses, the standard mechanism requires too much baggage. Sometimes I'd like to use tieing in a 10-line script; not having to create a package and populate it with a half dozen subs, which is alone 15 lines of red

Re: Simple multi-level tie

2003-12-18 Thread david nicol
On Wed, 2003-12-17 at 23:25, Andrew Sterling Hanenkamp wrote: tie my %hash, 'Tie::HashWrapper', \%wrappee, -inflate_value = sub { thaw(shift) }, -deflate_value = sub { freeze(shift) }; $hash{a}{complicated}[4]{data} = [ 'structure' ]; warning: the above will not autovivify.

Re: Simple multi-level tie

2003-12-18 Thread david nicol
What I want to know is, is Tie::HashWrapper a good name? If you don't like that name, what might you call it? HashWrapper sounds kind of dorky to me, but that's what first came to mind and I didn't want to spend all day trying to name it, I wanted to play code monkey. Cheers, Sterling I

Re: Simple multi-level tie

2003-12-18 Thread david nicol
On Thu, 2003-12-18 at 14:11, A. Pagaltzis wrote: I like them better as well, but I think (in|de)flate is too specific considering the generic nature of these filtering tie modules. I can't think of any better terminology of my own; maybe it would be best to simple reuse the names we're already

Simple multi-level tie

2003-12-17 Thread Andrew Sterling Hanenkamp
I would like the ability to store a complicated record inside of a DBM file. I looked in the usual places and perldoc -q DBM gives me: Either stringify the structure yourself (no fun), or else get the MLDBM (which uses Data::Dumper) module from CPAN and layer it on top of

Re: Simple multi-level tie

2003-12-17 Thread Mark Stosberg
On Wed, Dec 17, 2003 at 02:00:23PM -0600, Andrew Sterling Hanenkamp wrote: Therefore, I went in search of a solution to automate the stringification. I didn't find anything other than MLDBM for doing something like this and it seems like a little much for my purposes. All I need is

Re: Simple multi-level tie

2003-12-17 Thread david nicol
On Wed, 2003-12-17 at 14:00, Andrew Sterling Hanenkamp wrote: Therefore, I went in search of a solution to automate the stringification. I didn't find anything other than MLDBM for doing something like this and it seems like a little much for my purposes. All I need ... As I understand it,

Re: Simple multi-level tie

2003-12-17 Thread Andrew Sterling Hanenkamp
being misunderstood or no one has an answer to my questions. I believe I was asking for it with the subject line of Simple multi-level tie. What I should have wrote is Wrapping hashes with arbitrary inflate/deflate methods. This is a tool that adds syntactic sugar to hashes. I developed

Re: Simple multi-level tie

2003-12-17 Thread Randy W. Sims
On 12/18/2003 12:25 AM, Andrew Sterling Hanenkamp wrote: Wrapping hashes with arbitrary inflate/deflate methods. This is a tool that adds syntactic sugar to hashes. I developed it for the purpose of making complicated storage in hashes tied to DBM files nicer. It doesn't matter if you use

RE: Simple multi-level tie

2003-12-17 Thread Hugh S. Myers
] Sent: Wednesday, December 17, 2003 1:00 PM To: Module Authors Subject: Simple multi-level tie I would like the ability to store a complicated record inside of a DBM file. I looked in the usual places and perldoc -q DBM gives me: Either stringify the structure yourself (no fun), or else