Re: Creating template from string

Fergal Daly <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.petal
Message-ID <[email protected]>
If you just replace the filename with "SCALAR(0x813cd9c)" then you'll
also get an md5 hash appended which would mean that changing the
string would be enough. However using "SCALAR(0x813cd9c)" would mean
that it would not persist between runs.

So to be clever you could do something like

$filename = "//strings/".md5sum("some salt".$string);

the // ensures the filename won't collide with a real file. The md5sum
and the "some salt" means that we have 2 md5sum in the cached filename
making it even less likely to have an md5 hash collision but the
filename for a string will be the same every time we run the program,

F

On 7/21/05, Michael Graham <magog-4YeSL8/OYKRWk0Htik3J/[email protected]> wrote:
> 
> > One thought though - how will Petal cache the complied version of a
> > template created from a string? Perhaps some sort of 'cache key' could
> > be passed to the constructor?
> 
> That's a good question.  I initially tried making a Petal subclass that
> didn't need a filename, but I got foiled by all the file caching stuff.
> 
> Since we can make strings look like filehandles, would a filehandle work
> just as well?
> 
> As for a cache key, maybe you could use "SCALAR(0x813cd9c)" or whatever
> the stringified version of the scalarref's address is?  It would mean
> that to change the template you'd have to pass in a new string, not just
> change the existing buffer.
> 
> 
> Michael
> 
> 
> --
> Michael Graham <magog-4YeSL8/OYKRWk0Htik3J/[email protected]>
> 
> 
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.