sub p_idiomatic { # Use a numeric sort to enforce that m is greater then n my ($m, $n) = sort { $b <=> $a } $_[0], $_[1]; # This is the same as: # my ($m, $n) = reverse sort { $a <=> $b } $_[0], $_[1]; # Holds the remainder my $r; # Insure that they are positive integers # Is their a better way to do this? if (($m < 1) || ($n < 1)) { die("Values must be positive integers."); } do {{ $r = $m % $n; $m = $n; $n = $r; }} until $r == 0; return $m; }