Storing Content "Within A Package"

fansipans on 2007-05-16T14:06:53

Had a hilarious DUH moment yesterday. I was trying to figure out the best way for my CGI::Application application to bundle in all it's html templates into it's own package so when installed there's nothing other than the perl modules, no other directories / web pages / sites to set up..., everything is in /usr/lib/perl5/5.8.4/MyApp and the Templates are in /usr/lib/perl5/5.8.4/MyApp/Templates

So I'm pondering, and pondering, thinking maybe I can tweak the low-level of Petal's code into treating filenames and perl modules interchangably, and if using a perl module, read in from the __DATA__ section or something...

Then I realize the entire problem is reduced down to one simple variable change to my cgiapp_init:

$self->template->config(
    default_type => 'Petal',
    include_paths => \@INC
);


So now CGI::Application looks for my templates, and finds them, as pure html, no __DATA__ jibba jabba, just easy. Huzzah!

DUH!


File::ShareDir

rjbs on 2007-05-16T22:30:02

Please consider using File::ShareDir instead.

Re:File::ShareDir

Alias on 2007-05-17T01:51:56

I concur.

Full Disclosure: I wrote it :)

Re:File::ShareDir

fansipans on 2007-05-17T13:56:17

Just what I was looking for! Thanks guys, and thanks Adam for the helpful code ;)