in reply to Returning Values from Subroutines
orsub add{ my $value1 = $_[0]; my $value2 = $_[1]; my $result = ($value1 + $value2); }
or evensub add{ my $value1 = $_[0]; my $value2 = $_[1]; ($value1 + $value2); }
all of which return the same result.sub add{ ($_[0] + $_[1]); }
I would probably do it as
so that it is clear what I am trying to return. But as the Scarecrow said, "People do tend to go both ways."sub add{ return ($_[0] + $_[1]); }
()-() \"/ `
|
|---|