Mega Code Archive

 
Categories / Perl / Subroutine
 

A subroutine is defined by the sub keyword and the block of code that follows

#!/usr/local/bin/perl -w     # Declare the subroutine named usage     sub usage     {        my ($program, $exitCode) = @_;        print "Usage: $program [-v] [-h]\n";        exit $exitCode;     }     usage ($0, 1);