Date: 15 Sep 2001 02:05:21 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: Perl (slurping) is TOO much fun
Message-Id: <slrn9q5dn4.9rg.damian@puma.qimr.edu.au>

Logan Shaw chose 14 Sep 2001 19:22:31 -0500 to say this:
>In article <slrn9q553h.920.damian@puma.qimr.edu.au>,
>Damian James <damian@qimr.edu.au> wrote:
>
>>Logan Shaw chose 14 Sep 2001 14:17:45 -0500 to say this:
>
>>>In article <slrn9q39rb.og2.damian@puma.qimr.edu.au>,
>>>Damian James <damian@qimr.edu.au> wrote:
>
>>>>for some operations it will be easier to slurp for now, then later tie() your
>>>>data structure to a disk file.
>
>>>Is there an easy tie() equivalent for this?
>
>>No. You are simply moving the 'modify in place' code from the main program
>>to the package containing the methods for working with the file the
>>variable is tie()ed to.
>
>I don't quite understand that sentence.  Are you saying that writing a
>Perl module moves the implementation of the hard bits into a module
>where nobody has to deal with it[1]?  That's fairly obvious...

[footnote moved]
>[1]  Except of course the module maintainer(s).

Sorry, that's exactly what I meant. Somebody does, of course, have to deal
with it as your footnote mentions. I was considering this in the absence of
an existing CPAN module that provides the functionality (and silently
avoiding volunteering to write one -- I'm not the other Damian :-).

>...and it
>doesn't sound like that's what you're saying anyway.

Sorry. It's Saturday morning and I'm posting in between bouts of clearing
the yard and looking at CNN. 

>The module would
>be a standard and general purpose one -- it wouldn't have to be
>extended by its user or anything like that to make it work.

Yeah. I was assuming user == maintainer in this case.

>>There is a Tie::Handle module on CPAN by Steffen Beyer, whose namespace has
>>been reclaimed by the synonymous core module, but which appears to have the
>>functionality required to do the above.
>
>I looked at that module, and to me it looks like what it does is allow
>you to tie filehandles to objects, so that you are using the filehandle
>interfaces to operate on in-memory objects.

I got this the other way around in my (I guess cursory) reading of the
docs. I would have tested it if not for the namespace conflict. A second
glance suggests you are right.

>What I am proposing is
>something more akin to Unix's mmap(), so that you can operate on what
>looks like a normal variable, but actually your changes are being
>written to disk when you do so.

Indeed, and effectively you are managing your own swap for that variable.
Exactly what I had in mind when bringing it up. ISTR there's a discussion
of precisely this in the other Damian's OOP book, though my copy is at
work. So, what next? I'm quite happy to help out in the production of such
a module, but can't help but thinking that two Australian Damians
contributing to CPAN at once is at the face of it absurd, especially
considering the grossly divergent levels of expertise :-).

Cheers,
Damian
-- 
@:=grep!(m!$/|#!..$|),split//,<DATA>;@;=0..$#:;while($:=@;){$;=rand
$:--,@;[$;,$:]=@;[$:,$;]while$:;push@|,shift@;if$;[0]==@|;select$,,
$,,$,,1/80;print qq x\bxx((@;+@|)*$|++),@:[@|,@;],!@;&&$/}  __END__
Just another Perl Hacker, ### rev 3.3 -- stupidectomy performed :-)


