Create a Subroutine in Perl
Creating a subroutine in Perl is fairly easy...
sub gy {
print "Hiya";
}
&gy;
Which Prints:
Hiya
-You can name your subroutine pretty much whatever you like. Here, we named it
gy
-We called, or executed, our subroutine with
&gy;
-Whenever called, our subroutine will print
Hiya
NOTE: We could have placed the
&gy; before the subroutine itself and everything would work just as well.
Copy and Paste Perl Code:
#!/usr/bin/perl
print "Content-type:text/html\n\n";
sub gy {
print "Hiya";
}
&gy;
exit;
Resources:
Passing a Variable or Value to a Subroutine in Perl
Click HERE to comment or discuss at iLoveTheCode GOOGLE Group