You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Neil Gunton <ne...@home.nilspace.com> on 2002/11/03 19:47:55 UTC

Global 'use strict' in 2.x

Hi Gerald, I'm trying to enforce 'use strict' in my [$ sub $] routines for
2.0b8. Is there any way to tell Embperl to use strict in every [$ sub $] without
having to do something like the following?

[$ sub hello $]
   [* use strict; my ($self, $name) = @_; *]
   Hello [+ $name +]!!!!
[$ endsub $]

I'd like to avoid having to put the 'use strict' explicitly in every [$ sub $].
I want the same effect as putting 'use strict' just once at the start of the
file. However when I put this it doesn't seem to affect anything inside the [$
sub $] blocks:

[# start of file #]
[* use strict; *]
[$ sub hello $]
   ...
[$ endsub $]

I really don't want to use [$ var $] in this context, I'd prefer to use 'my' to
declare my variables, since it's cleaner and more convenient for more complex
code.

If there's a way to set 'strict' on globally, then that would be great too.

This is being done in a subs file under Embperl::Object, via the Execute({object
=> 'file.epl'}) syntax.

I see there is a 'strict' method mentioned in the README.v2 for the Component
object, but there's no more detail about what this does or how to use it. Any
clues most welcome...

I'm in the process of trying to transition my existing 1.x based sites over to
2.x.

Thanks!

-Neil

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


Re: Global 'use strict' in 2.x

Posted by Neil Gunton <ne...@home.nilspace.com>.
Specific example...

base.epl:

[$ var $global $]
[- 
   $global = shift;
   $global->{core} = Execute ({object => 'Core.epl'});
   Execute ('*');
-]

Core.epl:

[$ sub hello $]
   [* use strict; my ($self, $name) = @_; *]
   Hello [+ $name +]!!!!
   <P>
[$ endsub $]

[$ sub goodbye $]
   [* my ($self, $name) = @_; *]
   [* $xxx = 123; *]
   Goodbye, [+ $name +] [+ $xxx +]
   <P>
[$ endsub $]

This results in output:

Hello Neil!!!! 

Goodbye, Neil 123 


Neil Gunton <ne...@home.nilspace.com> wrote:
> Gerald Richter <ri...@ecos.de> wrote:
> > > Hi Gerald, I'm trying to enforce 'use strict' in my [$ sub $] routines for
> > > 2.0b8. Is there any way to tell Embperl to use strict in every [$ sub $]
> > without
> > > having to do something like the following?
> > >
> > > [$ sub hello $]
> > >    [* use strict; my ($self, $name) = @_; *]
> > >    Hello [+ $name +]!!!!
> > > [$ endsub $]
> > >
> > > I'd like to avoid having to put the 'use strict' explicitly in every [$
> > sub $].
> > 
> > I think it should be enough to put it in the first sub, but then it is only
> > active inside of subs.
> 
> This does not seem to work at present. Specifically the case I have is
> 'Core.epl', which is Executed as an object from base.epl (using
> Embperl::Object). If I have two [$ sub $] in this file, and use strict in the
> first one, and not in the second, then the second one allows the use of
> arbitrary variables without complaint. If I use strict explicitly in every [$
> sub $], then it's enforced.
> 
> > Using [$var$] without any variables, should force strict in all parts of the
> > page
> 
> In my Core.epl, this results in an error:
> 
> [1383]ERR: 24: Error in Perl code: 'undef' is not a valid variable name at
> /www/vhosts/test.nilspace.com/htdocs/Core.epl line 1 
>     BEGIN failed--compilation aborted (in cleanup) 'undef' is not a valid
> variable name at
> /www/vhosts/test.nilspace.com/htdocs/Core.epl line 1 
>     BEGIN failed--compilation aborted at
> /www/vhosts/test.nilspace.com/htdocs/Core.epl line 1.
> 
> Thanks, as always, for your help!
> 
> All the best,
> 
> -Neil
> 
> ---------------------------------------------------------------------
> 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


Re: Global 'use strict' in 2.x

Posted by Neil Gunton <ne...@home.nilspace.com>.
Gerald Richter <ri...@ecos.de> wrote:
> Does it work if you say
> 
> [$var $dummy $]

No, that has no effect. Interestingly, I also noticed that

[$ varxxxxx $dummy $]

produced no error message!

To make sure it was really recompiling, I changed something in the output, and
that change appeared in the page.

I put the [$ var $dummy $] at the very start of the Core.epl, before all the [$
sub $] declarations.

Thanks again!

-Neil

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


Re: Global 'use strict' in 2.x

Posted by Gerald Richter <ri...@ecos.de>.
>
> > Using [$var$] without any variables, should force strict in all parts of
the
> > page
>
> In my Core.epl, this results in an error:
>

Does it work if you say

[$var $dummy $]

?

Gerald



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

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------




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


Re: Global 'use strict' in 2.x

Posted by Neil Gunton <ne...@home.nilspace.com>.
Gerald Richter <ri...@ecos.de> wrote:
> > Hi Gerald, I'm trying to enforce 'use strict' in my [$ sub $] routines for
> > 2.0b8. Is there any way to tell Embperl to use strict in every [$ sub $]
> without
> > having to do something like the following?
> >
> > [$ sub hello $]
> >    [* use strict; my ($self, $name) = @_; *]
> >    Hello [+ $name +]!!!!
> > [$ endsub $]
> >
> > I'd like to avoid having to put the 'use strict' explicitly in every [$
> sub $].
> 
> I think it should be enough to put it in the first sub, but then it is only
> active inside of subs.

This does not seem to work at present. Specifically the case I have is
'Core.epl', which is Executed as an object from base.epl (using
Embperl::Object). If I have two [$ sub $] in this file, and use strict in the
first one, and not in the second, then the second one allows the use of
arbitrary variables without complaint. If I use strict explicitly in every [$
sub $], then it's enforced.

> Using [$var$] without any variables, should force strict in all parts of the
> page

In my Core.epl, this results in an error:

[1383]ERR: 24: Error in Perl code: 'undef' is not a valid variable name at
/www/vhosts/test.nilspace.com/htdocs/Core.epl line 1 
    BEGIN failed--compilation aborted (in cleanup) 'undef' is not a valid
variable name at
/www/vhosts/test.nilspace.com/htdocs/Core.epl line 1 
    BEGIN failed--compilation aborted at
/www/vhosts/test.nilspace.com/htdocs/Core.epl line 1.

Thanks, as always, for your help!

All the best,

-Neil

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


Re: Global 'use strict' in 2.x

Posted by Gerald Richter <ri...@ecos.de>.
> Hi Gerald, I'm trying to enforce 'use strict' in my [$ sub $] routines for
> 2.0b8. Is there any way to tell Embperl to use strict in every [$ sub $]
without
> having to do something like the following?
>
> [$ sub hello $]
>    [* use strict; my ($self, $name) = @_; *]
>    Hello [+ $name +]!!!!
> [$ endsub $]
>
> I'd like to avoid having to put the 'use strict' explicitly in every [$
sub $].

I think it should be enough to put it in the first sub, but then it is only
active inside of subs.

Using [$var$] without any variables, should force strict in all parts of the
page

Gerald


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

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------



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