-- main::(gcd.pl:18)
die sprintf "Need two integer arguments, got %d", scalar(@ARGV) unless
@ARGV == 2;
basename is on.
highlight is off.
set auto list is on.
-- main::(gcd.pl:20)
my ($a, $b) = @ARGV[0,1];
gcd.pl [16-21]
16 }
17
18 die sprintf "Need two integer arguments, got %d", scalar(@ARGV) unless
19 @ARGV == 2;
20 -> my ($a, $b) = @ARGV[0,1];
21 printf "The GCD of %d and %d is %d\n", $a, $b, gcd($a, $b);
-- main::(gcd.pl:21)
printf "The GCD of %d and %d is %d\n", $a, $b, gcd($a, $b);
gcd.pl [17-21]
17
18 die sprintf "Need two integer arguments, got %d", scalar(@ARGV) unless
19 @ARGV == 2;
20 my ($a, $b) = @ARGV[0,1];
21 -> printf "The GCD of %d and %d is %d\n", $a, $b, gcd($a, $b);
-- main::(gcd.pl:9)
my ($a, $b) = @_;
gcd.pl [5-14]
5 # GCD. We assume positive numbers
6 sub gcd($$);
7 sub gcd($$)
8 {
9 -> my ($a, $b) = @_;
10 # Make: a <= b
11 ($a, $b) = ($b, $a) if ($a > $b);
12
13 return undef if $a <= 0;
14 return $a if ($a == 1) or ($b-$a == 0);
set auto list is off.
-- main::(gcd.pl:11)
($a, $b) = ($b, $a) if ($a > $b);
-- main::(gcd.pl:13)
return undef if $a <= 0;