You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Gerald Richter <ri...@ecos.de> on 2001/04/05 07:14:50 UTC

Re: Defining subs (was: A newbie question.)

>Yeah, I think I shouldn't put my sub-functions at the bottom.


Yes, that's because EMbperl 1.x compiles _and_ executes the code block by
block, so it doesn't see the sub definition at the end when it for the first
time execute the function call, because the sub didn't have compiled at this
time.

Embperl 2.0 first compiles everything and then runs the code, so you can put
your function definitions anywhere.

>Oh, there IS another solution.
>Using [* *] instead [- -] or [! !] solves this problem.
>But I am somewhat reluctant to use this because they says it's experimental
>and they didn't say to use it to define functions anywhere from the embperl
>docs.
>


If you only use the [* *] blocks to define you subroutines, it safe to use
them, also in 1.3

Gerald



>I wonder how other embperl users define subfunctions in the same HTML page
>or Are they all define sub functions in other files????
>
>Andy
>
>
>-----Original Message-----
>From: Andre Landwehr [mailto:andre.landwehr@gmx.net]
>Sent: Wednesday, April 04, 2001 11:27 AM
>To: embperl@perl.apache.org
>Subject: Re: A newbie question. -
>
>
>On Wed, Apr 04, 2001 at 10:34:26AM -0700, Andy Lim wrote:
>> The weired thing is, if I define this sub function at the top of this
HTML
>> page, it generates no error at all. It means I get into trouble when I
>> define sub-functions at the bottom of each web pages.
>> I also tried embperl's meta command to define this sub function and
called
>> it using "Execute" but I got still same error.
>>
>> What am I doing wrong?
>
>I suppose it has something to do with your [- -] and [! !]
>sections living in a different scope. I can confirm the behaviour
>but I could'nt find any other solution than putting the function
>at the top of the page either.
>
>Andre
>
>--
> /"\
> \ /
>  X  ASCII Ribbon campaign against HTML E-Mail
> / \
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
>For additional commands, e-mail: embperl-help@perl.apache.org
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org