By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,541 Members | 1,455 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,541 IT Pros & Developers. It's quick & easy.


P: 173

algebra: z = pr%q+w/x - y

Perl code for this is: $z = $p * $r % $q + $w / $x - $y;

Can someone please explain to me : in what order does Perl calculate the operators? What would be calculated first, second, third etc... why?

I just cant get my head around the algebra business..
How does perl simplify the above algebra?
Feb 21 '09 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 2.5K+
P: 3,503
What you are looking for is the "order of operations" for Perl. Perl always processes things in a pre-defined order. A quick google search reveals plenty of links or, you can open your copy of Learning Perl or any other basic Perl book and read about it.


Feb 21 '09 #2

Expert 2.5K+
P: 4,059
Its the same as math:

First do anything in parentheses
Then do any multiplication or division working left to right
then do any addition or subtraction working left to right

Why would you think perl would do it any different? If it did then the answer has the potential of not being correct.
Feb 21 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.