How to use subroutines in PERL

In PERL subroutines (sub) are like functions they can be called to preform repetitive tasks.

=Calling Subroutines= 1. $out = &subFunction;
 * Call a subroutines
 * &subFunction;
 * Call a sub to return a value

or

2. $out = subFunction;
 * Call a sub in a if statement
 * if ( &subFunction ) {}
 * have the sub return a 0 for false or 1 for true
 * Pass a variable into a sub
 * &subFunction($var1);
 * &subFunction($var1, $var2);

=Subroutines Structure=

sub subsName { print "hello\n"; }
 * Basic

sub subsName { my ($a, $b) = ($_[0], $_[1]); print "$a is the first var passed in, and $b is the second.\n"; }
 * Passing vars into a sub

sub subsName { my $a = $_[0]; $b = $a + 1; $b; }
 * Returning Values
 * Values are returned by being the last operation in the sub

sub subsName { my $a = $_[0]; if($a > 12){ return 1; } else { return 0; } }
 * Multiply return options

From HowTo Wiki, a Wikia wiki.