<?xml version="1.0" encoding="windows-1252"?>
<node id="88732" title="Re: Re: 0 illegal modulus?" created="2001-06-15 09:33:46" updated="2005-07-21 01:27:21">
<type id="11">
note</type>
<author id="81921">
Vynce</author>
<data>
<field name="doctext">
&lt;P&gt;
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'?  
&lt;/P&gt;
&lt;CODE&gt;
bash-2.04$ perl -e 'print 5 % foo'
Illegal modulus zero at -e line 1.
&lt;/CODE&gt;
so...
&lt;CODE&gt;
bash-2.04$ perl -e '$x = 5; $y = "foo"; print ($y ? $x % $y : $x); print "\n"'
Illegal modulus zero at -e line 1.
bash-2.04$ perl -e '$x = 5; $y = "foo"; print ($y*1 ? $x % $y : 0); print "\n"'
0
bash-2.04$ perl -e '$x = 5; $y = "foo"; print (($y*1) ? $x % $y : $x); print "\n"'
5
&lt;/CODE&gt;
&lt;P&gt;
as you can see, one still generates an error.  as for what to return if $y is zero, i had misread your original statement.  
&lt;/P&gt;
.
</field>
<field name="root_node">
87384</field>
<field name="parent_node">
87652</field>
</data>
</node>
