Returning Values
Perhaps we did not want our new subroutine to actually print the message. Instead, we would like it to return the string of the message, and then we will call print on it.
This is very easy to do with the return statement.
use strict;
sub HowdyEveryone {
my $greeting = "Hello everyone.\nWhere do you want to go with Perl today?";
 return "$greeting\n";

}
print &HowdyEveryone;

The special array @_ holds the values passed in as the function's arguments. Thus, the first argument to the function is in $_[0], the second in $_[1], and so on. The number of arguments is simply scalar(@_).

For example:
sub hypotenuse {
return sqrt( ($_[0] ** 2) + ($_[1] ** 2) );
}
$diag = hypotenuse(3,4);

# $diag is 5
Most subroutines start by copying arguments into named private variables for safer and more convenient access:
sub hypotenuse {
my ($side1, $side2) = @_;
return sqrt( ($side1 ** 2) + ($side2 ** 2) );
}