DanTheman DanTheman - 5 months ago 22
Perl Question

What is the meaning of the % operator?

I saw recently in on an answer here on Stackoverflow where a calculation was done to determine whether a value was odd or even. There was a

used which always returned 0 or 1 depending on the value it was compared with.

I am trying to figure out what the usage is of this
and even though I searched on google, I could only find
used in hash.

$result = $str % 2;

Thank you very much in advance.

Answer Source

It's the "modulo" operator, see perlop.

[...] computes the division remainder of its first argument with respect to its second argument.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download