You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by "Justin M. Harrison" <sh...@doublebagel.com> on 2002/07/28 09:09:16 UTC

[! And [-

Could anybody clarify the difference between [! !] and [- -] for me?

According to
http://perl.apache.org/embperl/pod/doc/Embperl.-page-3-.htm,

"Same as [- Perl Code -] with the exception that the code is only
executed at the first request. This could be used to define subroutines,
or do one-time initialization."

If you had a file with:

[- whatever -]

And one with:

[! whatever !]

What makes [! whatever !] so different from [- whatever -]? When is [-
whatever -] ever going to be executed twice?

Justin


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


Re: [! And [-

Posted by David Lloyd <ll...@rebel.net.au>.
Heh,

> Correct, because the sub definition hasn't changed. Of course invoking
> and running the subroutine still (potentially) happens every time, so
> that would be done with [- brackets.

...unless you only want the subroutine to load once and only once (for
whatever contrived reason one might invent).

DSL

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


Re: [! And [-

Posted by Gavin Carr <ga...@openfusion.com.au>.
On Sun, Jul 28, 2002 at 06:13:56PM -0400, Justin Harrison wrote:
> Hmm. I suppose that helps. I am assuming then, that it is cached between
> page requests?

Yep.

> If you define a sub routine with [! And reload the page, then it does
> not need to recompile the sub routine? 

Correct, because the sub definition hasn't changed. Of course invoking
and running the subroutine still (potentially) happens every time, so
that would be done with [- brackets.

-G

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


RE: [! And [-

Posted by Justin Harrison <sh...@doublebagel.com>.
Hmm. I suppose that helps. I am assuming then, that it is cached between
page requests?

If you define a sub routine with [! And reload the page, then it does
not need to recompile the sub routine? Or does it just plain skip
running it at all?

> -----Original Message-----
> From: Gavin Carr [mailto:gavin@openfusion.com.au] 
> Sent: Sunday, July 28, 2002 6:02 PM
> To: Justin M. Harrison
> Cc: embperl@perl.apache.org
> Subject: Re: [! And [-
> 
> 
> On Sun, Jul 28, 2002 at 03:09:16AM -0400, Justin M. Harrison wrote:
> > Could anybody clarify the difference between [! !] and [- -] for me?
> 
> <snip>
> 
> > What makes [! whatever !] so different from [- whatever -]? 
> When is [- 
> > whatever -] ever going to be executed twice?
> 
> [- whatever -] gets executed every time the page is 
> loaded/reloaded. [! whatever !] is executed exactly once, the 
> very first time that page 
> is hit; thereafter it's effectively ignored because it's 
> assumed whatever you've done there (like defining a 
> subroutine or doing a 'use') is persistent. Does that help or 
> confuse? :-)
> 
> Cheers,
> Gavin
> 
> -- 
> Fashion is a variable, but style is a constant - Programming Perl
> 


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


Re: [! And [-

Posted by Gavin Carr <ga...@openfusion.com.au>.
On Sun, Jul 28, 2002 at 03:09:16AM -0400, Justin M. Harrison wrote:
> Could anybody clarify the difference between [! !] and [- -] for me?

<snip>

> What makes [! whatever !] so different from [- whatever -]? When is [-
> whatever -] ever going to be executed twice?

[- whatever -] gets executed every time the page is loaded/reloaded.
[! whatever !] is executed exactly once, the very first time that page 
is hit; thereafter it's effectively ignored because it's assumed
whatever you've done there (like defining a subroutine or doing a 'use')
is persistent. Does that help or confuse? :-)

Cheers,
Gavin

-- 
Fashion is a variable, but style is a constant - Programming Perl

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