Why do I get a divide-by-zero error?
I found this forum thanks to an old post on how to check whether a number is an integer:
I wrote a one-line program to try this out, with unexpected results:
Originally Posted by KevinR
Why the error? Clearly, I'm dividing by seven. Here's a very similar one-liner that works as expected:
perl -e 'print "Result of division is not an integer.\n" if 14/7 =~/\D/'
Illegal division by zero at -e line 1.
Why does the first give a divide-by-zero error, while the second does not?
perl -e 'print "Fourteen divided by seven is two.\n" if 14/7 == 2'
Fourteen divided by seven is two.