[prev] [index] [next]

Defining Functions

Perl functions (or subroutines) are defined via sub, e.g.

sub sayHello {
    print "Hello!\n";
}

And used by calling, with or without &, e.g.

&sayHello;    # arg list optional with &
sayHello();   # more common, show empty arg list explicitly