Hi,
In a project I'm working on, I'd like to have some small and simple embperl subs located in a lib directory, in individual files (for the most part). Consequently, I would like to be able to import all of these files in a single call, like with something like this:
Execute({ inputfile => $req->{embperl_common_lib} . "/all.epl", import => 1, package => "SPOTNIK_COMMON" });
all.epl would have a bunch of epl's to import, like this:
[-
my $req = shift;
Execute( { inputfile => $req->{embperl_common_lib}.'/displaytime.epl', import => 1, package => "SPOTNIK_COMMON" } );
-]
But when I try to call a sub defined in displaytime.epl with the namespace of SPOTNIK_COMMON:: it says the sub doesn't exist.
Am I doing this the right way? Is there something I'm missing or something I should be doing differently?
Hi,
Defining your own namespace can lead to some problems. Another solution is to let Embperl handle de namespace and use the isa syntax in Execute, like:
Execute({isa => 'subs.epl'});
Your subs will be available as methods of the request_rec object passed as first param in @_ for all pages.
Another solution is to use the object: my $object = Execute({object => 'component.epl'});
Your subs will be available as methods of the returned reference, like: $object->function()
For loading your pages I suggest you to put the list of pages to be imported in a shared function but to execute the Execute statement inside each page, like:
Execute({isa => $_}) foreach modules();
where modules return a list of your epl pages to be loaded.
I encourage you to take a look at EmbperlObject since all of this would become easier.
-- Luiz Fernando B. Ribeiro Engenho Soluções para a Internet +55 11 4485-0136
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]