7.2 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 {
return "Hello everyone.\nWhere do you want to go with Perl today?\n";
}
print &HowdyEveryone;