Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^3: why is my for loop using modulo giving me a weird output

by 2teez (Vicar)
on Jun 28, 2015 at 07:16 UTC ( #1132344=note: print w/replies, xml ) Need Help??


in reply to Re^2: why is my for loop using modulo giving me a weird output
in thread why is my for loop using modulo giving me a weird output

Please read Corion again!

Is there difference between printing, what modulo operator returns and using it to test?

i.e

print 4%2; # or if (4%2 == 0) { # blah..blah... }
Is there a difference?

If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me

Replies are listed 'Best First'.
Re^4: why is my for loop using modulo giving me a weird output
by perlynewby (Scribe) on Jun 28, 2015 at 08:22 UTC

    print, you are performing the task print

    while when you use IF then you are checking to see if the statement is true or false, If true then go and do what's inside the brackets. False, then don't go inside the brackets

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2021-04-15 23:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?