in reply to Re^2: map BLOCK evaluation context
in thread map BLOCK evaluation context
Aha, you're right. The thing was that
was evaluated just likeprint "C:"; for (qq{ab cd}) { print /(\S+)/g or die; # prints "C:abcd", list context again } print "\n";
It can be fixed like this:print "C:"; for (qq{ab cd}) { print(/(\S+)/g) or die; } print "\n";
However seems "or" not always enforces scalar context:print "D:"; for (qq{ab cd}) { print /(\S+)/g || die; } print "\n";
printsmy @a = (1,2,3); print "X:"; print (0 || @a); print "\n"; print "Y:"; print (@a || 0); print "\n";
X:123 Y:3
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: map BLOCK evaluation context
by Athanasius (Archbishop) on Mar 08, 2013 at 15:43 UTC | |
by vsespb (Chaplain) on Mar 08, 2013 at 16:09 UTC |
In Section
Seekers of Perl Wisdom