[cgiapp] packages autouse?
Porta
julian.porta at gmail.com
Fri Jun 12 09:16:13 EDT 2009
niiiiiiiiiiiiicemuch closer, indeed.
On Fri, Jun 12, 2009 at 10:09 AM, Michael Peters <mpeters at plusthree.com>wrote:
> Porta wrote:
>
>> I saw it, but unless I use the superloader, it still need to define the
>> names of the modules I want to use.And, regarding the superloader, I'm
>> lazy
>> enough to want to use all the packages within a given folder, but not just
>> every possible module in the world...
>> Still, a good suggestion.
>>
>
> I usually do something similar with some of my mod_perl programs to preload
> them into memory but you could probably do something similar. You could use
> it like:
>
> use MyProject::AutoUse;
>
> And it could look something like:
>
> package MyProject::AutoUse;
> use File::Find qw(find);
>
> BEGIN {
> find(
> {
> wanted => sub {
> return unless m/\.pm$/;
> return if /^\.?#/; # skip emacs droppings
> my $module = $1;
> $module =~ s/\//::/g;
>
> my $pkg = "MyProject::$module";
> eval "use $pkg;";
> die "Problem loading $pkg:\n\n$@" if $@;
> },
> no_chdir => 1
> },
> '/path/to/project/lib/MyProject'
> );
> }
>
>
> caveat: not tested but should give you the general idea.
>
> --
> Michael Peters
> Plus Three, LP
>
>
>
> ##### CGI::Application community mailing list ################
> ## ##
> ## To unsubscribe, or change your message delivery options, ##
> ## visit: http://lists.openlib.org/mailman/listinfo/cgiapp ##
> ## ##
> ## Web archive: http://lists.openlib.org/pipermail/cgiapp/ ##
> ## Wiki: http://cgiapp.erlbaum.net/ ##
> ## ##
> ################################################################
>
>
More information about the cgiapp
mailing list