Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Why Perl boolean expression sometimes treated as lvalue?

by tobyink (Abbot)
on Feb 08, 2013 at 13:28 UTC ( #1017817=note: print w/ replies, xml ) Need Help??


in reply to Why Perl boolean expression sometimes treated as lvalue?

Hmmm... interesting disparity. The following may be of interest...

use v5.10; my ($a, $b) = (0, 0); sub lv :lvalue { $_[0] } lv($a || $b) = 2; lv($a && $b) = 1; say $a; say $b;
package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name


Comment on Re: Why Perl boolean expression sometimes treated as lvalue?
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1017817]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (15)
As of 2015-07-06 13:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (74 votes), past polls