in reply to mod function

$y % 3 == 0 && do { } $y % 3 || do { } do { } if $y % 3 == 0 do { } unless $y % 3

Or of course you could just drop the do: and use the code you posted!!!

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Replies are listed 'Best First'.
Re: Re: mod function
by sauoq (Abbot) on Nov 11, 2002 at 20:02 UTC

    Don't forget...

    unless ($y % 3) { }

    I think that, for the most part, I prefer the explicitness of if ($y % 3 == 0) { } though.

    -sauoq
    "My two cents aren't worth a dime.";
    
      I'm curious (genuinely curious, not picking a fight) as to why if (...) is more explicit than unless (...)? Is it because if is more ubiquitous?

        To me the advantage of:

        if ($y % 3 == 0) { }

        is that you are explicitly stating that you are testing for a modulus being zero.

        With:

        unless ($y % 3) { }

        you are saying you are interested in Perl's idea of the statement's truth/falsehood - which is a subtly different concept.