my $self = "some text";
my $nself = ~eval(q/"self is $self"/,:lang<perl5>);
then surely $nself should be "self is some text".
But it is not. $self is not set inside the eval in pugs.
But
say ~eval(q/"self is $self"/);
yields
"self is some text"
Is this correct behaviour?
If yes, then how can I use content from a scalar inside an eval with perl5?
> If I have the following
>
> my $self = "some text";
> my $nself = ~eval(q/"self is $self"/,:lang<perl5>);
>
> then surely $nself should be "self is some text".
>
> But it is not. $self is not set inside the eval in pugs.
>
> But
> say ~eval(q/"self is $self"/);
> yields
> "self is some text"
>
> Is this correct behaviour?
It's now fixed as of r14574 -- scalar lexical variables now pass into
Perl 5 just fine. Enjoy!
Oh, and you can now also write:
sub f ($x, $y) {
use v5;
$x + $y
}
say f(1,2); # 3
That is, any block that begins with "use v5;" is now handled by Perl
5. This should eliminate
some of the workarounds with eval('sub{}', :lang<perl5>), and it's
now made into Spec in S01 and S11.
Thanks,
Audrey