[comp.lang.perl] Take the mod of a variable?

brendan@cs.widener.edu (Brendan Kehoe) (12/04/90)

 Is there any way to do something like $blah % 2  ($blah mod 2) ? I couldn't
find anything in TFM.
 Tanks.

-- 
    Brendan Kehoe - Widener Sun Network Manager - brendan@cs.widener.edu
 Widener University in Chester PA              A Bloody Sun-vs-Dec War Zone
  "Hi there! Did you know that the very same technology that cleaned up the
Alaskan oil spill can be used to suck the fat out of your thighs & upper lip?"

merlyn@iwarp.intel.com (Randal Schwartz) (12/05/90)

In article <1990Dec03.160045.13310@cs.widener.edu>, brendan@cs (Brendan Kehoe) writes:
|  Is there any way to do something like $blah % 2  ($blah mod 2) ? I couldn't
| find anything in TFM.

Yeah, try $blah % 2. :-)

$ perl -e '$blah = 15; print $blah % 2;'
1

It isn't really in the manpage.  Basically, Perl expressions are
defined in terms of C expressions, and since % is not in the category
of "what C has that Perl doesn't"... Perl has it.

It's clearer in The Book (I know... that doesn't help just yet).

print "Just another Perl [book] hacker,"
-- 
/=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\
| on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III      |
| merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn |
\=Cute Quote: "Intel: putting the 'backward' in 'backward compatible'..."====/