You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Mike Sidoti <mm...@crtinc.com> on 2001/02/15 16:15:17 UTC

use strict?

Hi, I was wondering if it was possible to include support for use strict in 
embedded perl.  We have tried a number of things but nothing seems to work 
in the same manner as it would in a typical perl script.  We do not want to 
have to put "use strict" in every block of embperl code on a page.  Ideally 
it would either be a server environment setting or made usable with the 
[*  *] tags.  If we use the [* *] tags it works fine until it gets to text 
that is outside of any []s.  We get an error saying:

$___b must be defined....

So what we think is happening is the "use strict" is being scoped into what 
ever embperl code is used to process the regular plain text/html in the 
file.  However that code wasn't built with use strict, so it fails.  Has 
anyone else run into this?  Is this a bug?  If you could email me back at: 
mmsidoti@crtinc.com, i would appreciate it.  Thank you!

--mike


Re: use strict?

Posted by Gerald Richter <ri...@ecos.de>.
> This works fine, even though technically, if use strict was indeed place,
> it would choke on $var2 not being defined.  How ever, if I use the [- -]
> brackets instead of the [* *] ones, use strict is enforced throughout the
> document.

[* *] are experminetal in 1.3, there are also other problems with them e.g.
that [$ if .. $], doesn't affect [* *] blocks.

The [* *] is compiled brefore any other block, so the [$ var $] doesn't
affects [* *] (only all other blocks). If you really want to have use strict
and [* *] blocks, you have to write

[* use strict ; use vars qw{$___b} ; *]

(You may add more variables to the use vars). This should work .

[* *] works as expected in 2.0b1

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
-------------------------------------------------------------




Re: use strict?

Posted by Ilia Lobsanov <nu...@nurey.net>.
Do you *have* to use [* *] ? :-)

ilia.

On Thu, Feb 15, 2001 at 02:10:45PM -0500, Mike Sidoti wrote:
> Ilia,  thanks for responding, that does work, for most cases.  but take 
> this one:
> 
> <HTML>
> <BODY>
> [$ var $var1 $]
> 
> blah blah blah<BR>
> 
> [*
>          $var1 = "hello"
>          $var2 = ", how are you?";
> *]
> <HR>
> [* print $var1, $var2  *]
> 
> This works fine, even though technically, if use strict was indeed place, 
> it would choke on $var2 not being defined.  How ever, if I use the [- -] 
> brackets instead of the [* *] ones, use strict is enforced throughout the 
> document.  I am thinking that maybe this is a bug with the new [* *] 
> brackets. Atleast, from my point of view I think it is.  It could be a 
> design feature that I am just not aware of.  But I tend to think it is a 
> bug.  When we start playing around with use strict and the [* *] we start 
> getting errors saying $___b must be definied and other wierd ones.  We 
> havent been able to duplicate a specific situation that this occurs in 
> though....
> 
> --mike
> 
> 
> 
> 
> At 12:47 PM 2/15/01 -0500, Ilia Lobsanov wrote:
> >On Thu, Feb 15, 2001 at 10:15:17AM -0500, Mike Sidoti wrote:
> > > Hi, I was wondering if it was possible to include support for use 
> > strict in
> > > embedded perl.  We have tried a number of things but nothing seems to work
> > > in the same manner as it would in a typical perl script.  We do not 
> > want to
> > > have to put "use strict" in every block of embperl code on a 
> > page.  Ideally
> > > it would either be a server environment setting or made usable with the
> > > [*  *] tags.  If we use the [* *] tags it works fine until it gets to text
> > > that is outside of any []s.  We get an error saying:
> > >
> > > $___b must be defined....
> > >
> > > So what we think is happening is the "use strict" is being scoped into 
> > what
> > > ever embperl code is used to process the regular plain text/html in the
> > > file.  However that code wasn't built with use strict, so it fails.  Has
> > > anyone else run into this?  Is this a bug?  If you could email me back at:
> > > mmsidoti@crtinc.com, i would appreciate it.  Thank you!
> > >
> > > --mike
> >
> >
> >Try this:
> >   [$var $var1 $var2 $]
> >
> >I think that makes the whole embperl document act under the `use strict` 
> >pragma.
> >
> >
> >--
> >Ilia Lobsanov
> >Nurey Networks Inc.
> >http://www.nurey.net/
> 

-- 
Ilia Lobsanov
Nurey Networks Inc.
http://www.nurey.net/

Re: use strict?

Posted by Mike Sidoti <mm...@crtinc.com>.
Ilia,  thanks for responding, that does work, for most cases.  but take 
this one:

<HTML>
<BODY>
[$ var $var1 $]

blah blah blah<BR>

[*
         $var1 = "hello"
         $var2 = ", how are you?";
*]
<HR>
[* print $var1, $var2  *]

This works fine, even though technically, if use strict was indeed place, 
it would choke on $var2 not being defined.  How ever, if I use the [- -] 
brackets instead of the [* *] ones, use strict is enforced throughout the 
document.  I am thinking that maybe this is a bug with the new [* *] 
brackets. Atleast, from my point of view I think it is.  It could be a 
design feature that I am just not aware of.  But I tend to think it is a 
bug.  When we start playing around with use strict and the [* *] we start 
getting errors saying $___b must be definied and other wierd ones.  We 
havent been able to duplicate a specific situation that this occurs in 
though....

--mike




At 12:47 PM 2/15/01 -0500, Ilia Lobsanov wrote:
>On Thu, Feb 15, 2001 at 10:15:17AM -0500, Mike Sidoti wrote:
> > Hi, I was wondering if it was possible to include support for use 
> strict in
> > embedded perl.  We have tried a number of things but nothing seems to work
> > in the same manner as it would in a typical perl script.  We do not 
> want to
> > have to put "use strict" in every block of embperl code on a 
> page.  Ideally
> > it would either be a server environment setting or made usable with the
> > [*  *] tags.  If we use the [* *] tags it works fine until it gets to text
> > that is outside of any []s.  We get an error saying:
> >
> > $___b must be defined....
> >
> > So what we think is happening is the "use strict" is being scoped into 
> what
> > ever embperl code is used to process the regular plain text/html in the
> > file.  However that code wasn't built with use strict, so it fails.  Has
> > anyone else run into this?  Is this a bug?  If you could email me back at:
> > mmsidoti@crtinc.com, i would appreciate it.  Thank you!
> >
> > --mike
>
>
>Try this:
>   [$var $var1 $var2 $]
>
>I think that makes the whole embperl document act under the `use strict` 
>pragma.
>
>
>--
>Ilia Lobsanov
>Nurey Networks Inc.
>http://www.nurey.net/


Re: use strict?

Posted by Ilia Lobsanov <nu...@nurey.net>.
On Thu, Feb 15, 2001 at 10:15:17AM -0500, Mike Sidoti wrote:
> Hi, I was wondering if it was possible to include support for use strict in 
> embedded perl.  We have tried a number of things but nothing seems to work 
> in the same manner as it would in a typical perl script.  We do not want to 
> have to put "use strict" in every block of embperl code on a page.  Ideally 
> it would either be a server environment setting or made usable with the 
> [*  *] tags.  If we use the [* *] tags it works fine until it gets to text 
> that is outside of any []s.  We get an error saying:
> 
> $___b must be defined....
> 
> So what we think is happening is the "use strict" is being scoped into what 
> ever embperl code is used to process the regular plain text/html in the 
> file.  However that code wasn't built with use strict, so it fails.  Has 
> anyone else run into this?  Is this a bug?  If you could email me back at: 
> mmsidoti@crtinc.com, i would appreciate it.  Thank you!
> 
> --mike
 

Try this:
  [$var $var1 $var2 $]

I think that makes the whole embperl document act under the `use strict` pragma.


-- 
Ilia Lobsanov
Nurey Networks Inc.
http://www.nurey.net/