Create a subroutine

What is a Subroutine?

A subroutine is block of reusable code that you create within your program.

Instructions within the subroutine can be called or executed from the main program more then once. This makes redundant tasks simpler.

  1. Create a new script with this code:

    #!/usr/bin/perl
    print "Content-Type: text/html \n\n";

    print "Program starts.\n";

    &bigHeader;

    print "Program ends.\n";

    # subroutines below this line

    sub bigHeader {
    print "<h1>Welcome to Acme Auto!</h1>\n";
    }

Want ad-free tutorials like these for classroom use? Get them at Visilearn.com.