Neil,

let me start with end of your mail...

> What do you think, Gerald? Does this behavior constitute a bug, or am I
> merely using Embperl incorrectly in this instance?

The second thing is true. Let me explain why it is not a bug:


> I thought that if
> you included a file using
>
> Execute ({inputfile => 'filename.html', package => __PACKAGE__})
>
> then this was _equivalent_ to including that file inline in the current
> file (this was the subject of one of my early questions to the mailing
> list).

No, not fully. You compile the file in the same namespace. From the Perl
point of view it's the same as an inline inlcude, but the Execute ('x#y') is
handled by Embperl itself, and Embperl keeps it's subroutines associated
with filenames and not packagenames. Is this more clear now?

>
> In any case, I believe I have now isolated the minimal case which can
> demonstrate the "error" which I am experiencing. Let's say we are using
> base.html and EmbperlObject as stated previously, and in addition we
> have two files, xxx.html and yyy.html. The files are as follows:
>
> base.html:
> [- Execute ({inputfile => '*', package => __PACKAGE__}) -]
>
> xxx.html:
> [$ sub foo $]
>    xxx
> [$ endsub $]
>
> <A HREF="yyy.html">yyy</A>
>
> <H1>xxx: [- foo -]</H1>
>
> yyy.html:
> [$ sub foo $]
> yyy
> [$ endsub $]
>
> <A HREF="xxx.html">xxx</A>
>
> <H1>yyy: [- foo -]</H1>
>
> If you point your browser at xxx.html and then flip between the two
> using the link (making sure you hit "reload" to refresh), you will see
> that the sub foo gets mixed up. So when we are displaying xxx.html,
> sometimes we get the "yyy" string, and vice versa.
>
> Looking at this example, I would have intuitively expected sub foo to be
> independent between xxx.html and yyy.html, because it is locally defined
> in each file. But on the other hand, both xxx.html and yyy.html are
> included from base.html into the same namespace, so I can see why the
> cache might get confused... but still, I feel that the two files should
> be independent. The subs should not be mixed up. Do you agree?
>

No I don't agree. Embperl doesn't mix up the two subroutines, you can call
both with the Execute ('x#y') syntax and it works, but Perl cannot keep them
separate because you compile then in the same namespace. The subrountine
that is compiled as second one, will stay and called for any further
invocation (which sub this is may be different for different Apache childs).
You tell Perl to use the same namespace, you cannot expect that Perl can
define to subroutines with the same name in the same namespace...

>
> I use __PACKAGE__ because I have global variables which are set up in
> various different files (such as init.html and constants.html) which are
> executed before '*', and it is just more convenient to include all these
> in the same namespace. I don't doubt there's some kind of workaround.
>

By includeing them in the same namespace you also need much more memory,
because you have to compile all common files for every file you invoke. To
pass "global" data around, use the Embperl Request Object.
http://perl.apache.org/embperl/EmbperlObject.pod.5.html#Example_for_using_me
thod_calls contains an example (the $self -> {fontsize} )

Hope this helps

Gerald



-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     [EMAIL PROTECTED]         Voice:    +49 6133 925151
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to