jrp370 has asked for the wisdom of the Perl Monks concerning the following question:
every time i try to run my program (driver) is receive the following error message, arithmetic.pm did not return a true value at ./driver line 9, begin failed--compilation aborted at ./driver line 9 can anyone help me sort this out? thank you very much
#!/usr/bin/perl -w #Driver #program by James Park #last revision on friday, september 23rd. #purpose this program driver will call on the arithmetic.pm file to fi +nd and use the correct #functions use strict; use lib "."; use arithmetic; sub menu{ print"please choose an option from the menu below:"; print"1. use the greatest common devisor function."; print"2. use the least common multiple function."; my $m = <STDIN>; print"enter the first number: "; my $a = <STDIN>; print "enter the second number:"; my $b = <STDIN>; if ($m = 1 ){ my $gcd; $gcd = arithmetic::gcd($a,$b); print "gcd of ($a,$b) = $gcd"; }else{ my $lcm; $lcm = arithmetic::lcm($a,$b); print "lcm of ($a,$b)= $lcm"; } }
#arithmetic.pm #!/usr/bin/perl -w use strict; package arithmetic; sub gcd() { my ($a, $b) = @_; ($a,$b) = ($b,$a) if $a > $b; while ($a) { ($a, $b) = ($b % $a, $a); } return $b; } sub lcm { my ($a,$b)=@_; return $a*$b/&gcd($a,$b); } ]
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: using libaries
by keszler (Priest) on Sep 29, 2011 at 00:45 UTC | |
|
Re: using libaries
by Anonymous Monk on Sep 29, 2011 at 11:50 UTC |