# File: pythagoraSub.pl # Title: Use subroutine with 2 parameters # Author: Mihaela Malita # C:\myPerl>perl pythagoraSub.pl # Input first side? 3 # Input second side? 4 # Hypothenuse is 5 # Bye #### Computes in a right triangle the hypothenuse given 2 sides ### print "Input first side? "; $n = ; chop($n); # read $n print "Input second side? "; $m = ; chop($m); # read $m print "Hypothenuse is ", hypo($n,$m); print "\nBye"; exit; #### Subroutine hypo does the job ### #### arguments are send from the main program in an array called @_ ### sub hypo{ my($x,$y) = @_; # $x is a local PARAMETER takes value of $n, $y is $m return sqrt($x**2 + $y**2); # result is computed and returned }