Subroutines
Defining Subroutines
- You can reuse a segment of Perl code by placing it within a subroutine
- The subroutine is defined using the sub keyword and a name
- The subroutine body is defined by placing code statements within
the { } code block symbols
sub MySubroutine
{
# Your Perl code goes here.
}
- Subroutines may be recursive (call themselves)