Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2017-07-25 03:37 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (363 votes). Check out past polls.