> >but I continue to
> > play with the problem and have come up with more possible behavioral
> > clues. In my previous email, I said that Execute('#foo') worked.
> > However, I now discover that it ONLY works if [$ sub foo $] is in the
> > same file as the call to Execute('#foo'). When I move the [$ sub $]
> > definition out into a subroutines file (which is Executed to import the
> > subs) then I consistently get an error "Call to unknown Embperl macro
> > foo" on Execute('#foo').
>
> This is exactly as it should be. To call an sub in another file via Execute
> you have to provide the filename, e.g.
>
> Execute ('bar.html#foo') ;
Ok - this is different from my previous understanding. 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). Hence I thought that
Execute ('#foo')
would work if the file had been included in this way.
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?
I realize now that the crucial thing here is the use of __PACKAGE__ in
the call from base.html. Not having this in my initial minimal case was
why it worked ok, and it is the presence of __PACKAGE__ that causes the
bug (if it is in fact a bug) to manifest.
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.
What do you think, Gerald? Does this behavior constitute a bug, or am I
merely using Embperl incorrectly in this instance?
Anyway, it's a relief to finally pin down exactly what causes this thing
to happen! It was driving me nuts.
Thanks again for your time,
-Neil
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]