You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by "Martin A. Langhoff" <ml...@scim.com.ar> on 2000/06/02 13:47:10 UTC
Variable declaration / scope
hi list,
I've been developing with Embperl for a few months now, and I've
already RTFM a few times, but still some issues remain obscure to me. So
here it is: Why can't I declare a lexical variable inside a [- -] block?
[- my $foo -] will make Embperl cry loud if $foo was not declared as a
global.
And if I change $foo with %foo in the previous example, it seems
that declaring [- my $foo -] when it already is a global wipes %foo's
contents clean when the [- -] block is over.
I can, of course, declare [! my $foo !] and get it to work, but
that's another issue...
martin
-- --
To understand recursion, one must first understand recursion.
-- --
- Martin Langhoff @ S C I M Multimedia Technology -
- http://www.scim.net | God is real until -
- mailto:mlangho@scim.net | declared integer -
RE: Variable declaration / scope
Posted by Gerald Richter <ri...@ecos.de>.
hi,
>
> I've been developing with Embperl for a few months now, and I've
> already RTFM a few times, but still some issues remain obscure to me. So
> here it is: Why can't I declare a lexical variable inside a [- -] block?
> [- my $foo -] will make Embperl cry loud if $foo was not declared as a
> global.
>
> And if I change $foo with %foo in the previous example, it seems
> that declaring [- my $foo -] when it already is a global wipes %foo's
> contents clean when the [- -] block is over.
>
> I can, of course, declare [! my $foo !] and get it to work, but
> that's another issue...
>
Normaly there shouldn't be a problem with declaring lexical inside a Embperl
block. You only have to take care about closures:
http://perl.apache.org/guide/perl.html#my_Scoped_Variable_in_Nested_S
If this is not your problem, can you send a short example that shows your
problem
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 925151
WWW: http://www.ecos.de Fax: +49 6133 925152
-------------------------------------------------------------