### Re^2: Perl 5.10: switch statement demo

by ikegami (Pope)
 on Dec 19, 2007 at 22:32 UTC ( #657991=note: print w/replies, xml ) Need Help??

in reply to Re: Perl 5.10: switch statement demo
in thread Perl 5.10: switch statement demo

I wonder why you switched from "when the remainder is zero" to "when not the remainder". (Reminds me of the baby in Dinosaurs: "Not the Momma! Not the Momma!")

Update: Nevermind, I guess it can be read "when no remainder". I guess I don't think of a remainder of zero as there being no remainder, so it looks weird to me.

Replies are listed 'Best First'.
Re^3: Perl 5.10: switch statement demo
by talexb (Canon) on Dec 20, 2007 at 16:26 UTC

The modulo construct can also be thought of as 'divisible by' -- so \$foo % 3 checks to see if \$foo is divisible by 3. Or at least that's the way my brain works.

Alex / talexb / Toronto

"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

That's backwards. \$foo % 3 checks if \$foo *isn't* divisible by 3. not \$foo % 3 would deceptively check if is divisible by 3.

OK, OK. :) And in this tiny corner of the universe, I'm pretending that a result of 0 means "Yes! It's divisible!". :)

Your confusion was not my intention.

Alex / talexb / Toronto

"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Create A New User
Node Status?
node history
Node Type: note [id://657991]
help
Chatterbox?
 [huck]: you cant sort a hash, hashs have their own unchangeable order [huck]: but you can print a hash in sorted order [huck]: my @aa; for my \$key (sort keys %hash){push @aa,\$key,\$hash{\$ke y};} print join(',',@aa)."\n ";

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2018-05-27 08:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
World peace can best be achieved by:

Results (194 votes). Check out past polls.

Notices?