algebraic operation question

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

•  Subject
• Author
• Posted on
Hi All,

When using algebraic operation, do I need to always
be explicit?

The following always gives correct answer:

if (( "\$LatestRev" ge "\$OldRev" ) &&
( \$LatestRevLength == \$OldRevLength ))

The following gets it wrong occasionally:

if ( "\$LatestRev" ge "\$OldRev"  &&
\$LatestRevLength == \$OldRevLength )

What is the sequence of algebraic operations and
which has dominance over the other?  (I take it
"&&" has dominance over "ge" and "==".)

-T

Re: algebraic operation question

See the first section of 'perldoc perlop': Operator Precedence and
Associativity.

--
Jim Gibson

Re: algebraic operation question

On 08/11/2015 06:45 PM, Jim Gibson wrote:

Done.  Right there a the top too!   Thank you!

You know it occures to me that for readability, I should
use the () even when I don't have to.

Perl operators have the following associativity and precedence,
listed from highest precedence to lowest.  ...

left           terms and list operators (leftward)
left           ->
nonassoc    ++ --
right       **
right       ! ~ \ and unary + and -
left           =~ !~
left           * / % x
left           + - .
left           << >>
nonassoc    named unary operators
nonassoc    < > <= >= lt gt le ge
nonassoc    == != <=> eq ne cmp ~~
left           &
left           | ^
left           &&
left           || //
nonassoc    ..  ...
right       ?:
right       = += -= *= etc.
left           , =>
nonassoc    list operators (rightward)
right       not
left           and
left           or xor