Subroutine

A Routine or Subroutine also referred to as a function, procedure, and subprogram, is a portion of code that may be called and executed anywhere in a program. For example, a routine may be used to save a file or display the time. Instead of writing the code each time these commonly performed tasks are needed, routines are created and called when these tasks need to be performed. Below is a basic example of a Perl subroutine.

Subroutine Example

&hello;

sub hello {
     print "Hello World!n";
}

In the above example, a user could call the "hello" subroutine (in this example, by typing &hello;) anywhere within the program and have the program print "Hello World!". After the subroutine has completed, the program goes to the return address, which is directly after &hello; and runs any additional code.

© Copyright 2019 FreshSites Limited. Registered in England and Wales no. 7812509
Website Design by Pyxal
Subroutine | FreshSites Subroutine | FreshSites Subroutine | FreshSites Subroutine | FreshSites Subroutine | FreshSites Subroutine | FreshSites Subroutine | FreshSites Subroutine | FreshSites Subroutine | FreshSites Subroutine | FreshSites Subroutine | FreshSites Subroutine | FreshSites Subroutine | FreshSites Subroutine | FreshSites