perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Angus Lees <...@inodes.org>
Subject Re: session question
Date Sat, 11 Dec 2004 00:40:50 GMT
At Thu, 09 Dec 2004 21:05:24 -0600, Will Schroeder wrote:
> 1: in a pattern match like [$ if ( $fdat{QC} =~ m/(\d+)/  ) $]
> [- $num = $1 -]
> for example. The $1 variable never seems to get populated during the
> match like in a regular old perl script.

aiui, the value of $1, etc variables are "lexically scoped" in perl.

so this should work fine:
[-
  if ( $fdat{QC} =~ m/(\d+)/ ) {
    $num = $1;
  }
-]

whereas your code gets turned into something more like this by
embperl:

 if ( eval { $fdat{QC} =~ m/(\d+)/ } ) {
   eval { $num = $1 };
 }

so $1 loses its value across embperl blocks, in the same way that "my"
variables, etc are also limited to a single embperl block
(ignoring [* *] blocks for the moment).

-- 
 - Gus


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


Mime
View raw message