in reply to grep integer and fractional part from a division (modulus ?)

my ($int, $remain) = (int 301/60, 301%60);

This is a solution, but I doubt that this is what you were after. I don't see any clear way of doing it while not repeating the 301 and 60.

Minor update: Changed variable name $frac to better name $remain as this is what it is, a remainder instead of a fraction. Samy_rio++ for spotting this.

-- Hofmator

Replies are listed 'Best First'.
Re^2: grep integer and fractional part from a division (modulus ?)
by rhesa (Vicar) on Aug 11, 2006 at 12:05 UTC
    I think this is the best way to write it. You could assign the numbers to variables first (they likely are already), but the principle of your solution is clear.

    One could write

    ($q, $r) = ( int( ($n=301) / ($d=60) ) , $n % $d );
    but that is definitely less clear, even though it avoids the repetion of the numbers.