I have been working with perl for about two months now; it just occurred to me that I don't know how to set default arguments for subroutines. Here is what I considered:
sub hello {
print @_ || "Hello world";
}
And that works fine for if all you needed was one argument. How would you set default values for multiple arguments? I was going to do this:
sub hello {
my $say = $_[0] || "Hello";
my $to = $_[1] || "World!";
print "$say $to";
}
But that's a lot of work... There must be an easier way; possibly a best practice? Thanks!