Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re^2: $1 not "freezing" in an addition

by tobyink (Abbot)
on Dec 14, 2012 at 15:08 UTC ( #1008855=note: print w/replies, xml ) Need Help??

in reply to Re: $1 not "freezing" in an addition
in thread $1 not "freezing" in an addition

Here's another fun example...

use 5.010; my $z = 0; sub xxx () { $z = 1; return 2; } sub yyy () { my $zz = $z; $z = 0; return 2 + $zz; } if (xxx + yyy == yyy + xxx) { say "Addition is commutative"; } else { say "The world has gone haywire!"; }

See addition; commutativity; etc.

Don't write functions with side-effects. And if you really must write functions with side-effects, be careful using them in expressions.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (6)
As of 2016-10-24 14:38 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (307 votes). Check out past polls.