perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Luiz Fernando B. Ribeiro" <>
Subject Re: execute problems
Date Wed, 03 Dec 2003 20:46:23 GMT
On Wed, 3 Dec 2003 18:41:16 +0100, Kaare Rasmussen <> wrote:

> If I do this
>   Execute ({inputfile => 'findList.sub', import => 1});
> Then this line in findList.sub will not be executed if it's outside the 
> subs
> in findList.sub:
> [- $req = shift -]
> But I'm using the $req object, so I'll try this:
>   Execute ('findList.sub');
> OK except that the subs are not imported now.
> Will I have to do this to get what I want - which is both the req object 
> the sub routines ?
>   Execute ({inputfile => 'findList.sub', import => 1});
>   Execute ('findList.sub');

If you need just the subs in a file you can import or use the "objet" 
$obj = Execute({object => 'findList.sub'});

and then use a pseudo-constructor passing the $req object and store the 
$req inside the object:

After this you call your subs as methods:

But with this technique you have to change your subs to receive the $obj 
(or $self if you like) as the first parameter in @_.

You can make it even more smart if you are using EmbperlObject. If you 
execute your files with the "isa" syntax in the "base template" file you 
can call your subs as methods of the $req object.

This is just one of the alternatives.

Other solution is to pass the $req to every sub you call in the file 

Luiz Fernando B. Ribeiro
Engenho Soluções para a Internet

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message