Re.pl: a variable that does not match the inner block

Example:

~ $ re.pl
$ { my $abc = 10 ; $abc }
10
$ $abc
10
$ 

Is this a documented version?

+3
source share
4 answers

This seems a bug in Lexical :: Persistence , which Devel :: REPL is used to control the lexical environment, continuing a few evals.

Here is a demonstration of an error without Devel :: REPL. This code incorrectly creates a value of $abc10, even if it is in the inner area.

use strict;
use warnings;
use Lexical::Persistence;

my $environment = Lexical::Persistence->new;
$environment->call(sub {
    my $foo = shift;
    { my $abc = 10 };
    return $foo;
});

print $environment->get_context('_')->{'$abc'};

I reported an error against the module, let's see what happens!

, ( Devel:: REPL), Eval:: WithLexicals :

use strict;
use warnings;
use Eval::WithLexicals;

my $environment = Eval::WithLexicals->new;
print $environment->eval('{ my $abc = 10 ; $abc }'), "\n";
print $environment->eval('$abc'), "\n";

10, , eval Global symbol "$abc" requires explicit package name.

+6

$a $b - , . . perldoc -f sort.

+3

$a $b.

Perlvar (Perl ):

$  $​​STRONG >

sort(), . - $a $b ( use vars our()) strict 'vars'. lexicalize my $a my $b, sort() .

+2

This does not happen if you run your code directly in the Perl interpreter:

$ perl -we '{ my $abc = 10 ; print "($abc)\n"; }; print "($abc)\n";'
Name "main::abc" used only once: possible typo at -e line 1.
(10)
Use of uninitialized value $abc in concatenation (.) or string at -e line 1.
()

You may have found a bug in Devel :: REPL .

0
source

All Articles