vr has asked for the wisdom of the Perl Monks concerning the following question:
I'm puzzled with this little problem (a fragment is to reproduce it, never mind what it was doing originally):
C:\>perl -we "sub parse{${$_[0]}=~/\Gfoo/gc or die} parse \('foo') for + 1..2" Died at -e line 1. C:\>perl -we "sub parse{${$_[0]}=~/\Gfoo/gc or die} parse \(''.'foo') +for 1..2" C:\>perl -MO=Deparse -we "sub parse{${$_[0]}=~/\Gfoo/gc or die} parse +\('foo') for 1..2" BEGIN { $^W = 1; } sub parse { die unless ${$_[0];} =~ /\Gfoo/cg; } parse \'foo' foreach (1 .. 2); -e syntax OK C:\>perl -MO=Deparse -we "sub parse{${$_[0]}=~/\Gfoo/gc or die} parse +\(''.'foo') for 1..2" BEGIN { $^W = 1; } sub parse { die unless ${$_[0];} =~ /\Gfoo/cg; } parse \'foo' foreach (1 .. 2); -e syntax OK
I'd expect, because of constants folding, two fragments of code to behave the same. Also, see B::Deparse output. Yet code runs differently.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: What's going on with either constants folding or B::Deparse output in this case? (updated)
by haukex (Archbishop) on Feb 25, 2017 at 11:58 UTC | |
by vr (Curate) on Feb 25, 2017 at 12:40 UTC | |
by haukex (Archbishop) on Feb 25, 2017 at 17:13 UTC | |
|
Re: What's going on with either constants folding or B::Deparse output in this case?
by shmem (Chancellor) on Feb 25, 2017 at 23:21 UTC |