Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Re: 0 illegal modulus?

by Vynce (Friar)
on Jun 15, 2001 at 13:33 UTC ( #88732=note: print w/ replies, xml ) Need Help??


in reply to Re: 0 illegal modulus?
in thread 0 illegal modulus?

well, i actually said $y*1 to force that into a numerical context. if you don't, then what if $x is 5 and $y is 'foo'?

bash-2.04$ perl -e 'print 5 % foo' Illegal modulus zero at -e line 1.
so...
bash-2.04$ perl -e '$x = 5; $y = "foo"; print ($y ? $x % $y : $x); pri +nt "\n"' Illegal modulus zero at -e line 1. bash-2.04$ perl -e '$x = 5; $y = "foo"; print ($y*1 ? $x % $y : 0); pr +int "\n"' 0 bash-2.04$ perl -e '$x = 5; $y = "foo"; print (($y*1) ? $x % $y : $x); + print "\n"' 5

as you can see, one still generates an error. as for what to return if $y is zero, i had misread your original statement.

.


Comment on Re: Re: 0 illegal modulus?
Select or Download Code
Re: Re: Re: 0 illegal modulus?
by Anonymous Monk on Jun 15, 2001 at 14:04 UTC
    Dont use *1! Surely "foo" *is* an illegal modulus. And "0" is still false.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (14)
As of 2014-08-27 17:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (247 votes), past polls