Home / code / cgi

Subroutines

The subroutine is separated function within the script. Subroutines always start with sub and name of the subroutine. You call on the subroutine withe the & (ampersand) followed by the name of the subroutine.

$num=10;
&print_result;

$num++;
&print_result;

$num*=5
&print_result;

sub print_result
{
  print "\$num is $num \n";
}

 

TOP

Latest script:

 

Books: