 |

Table of Contents
Main
-Home
-Advertising
-Contact Us
-Updates
Perl Overview:
-What is Perl?
Getting Started:
-Installing Perl
/ Unix
/ Windows
Writing Code:
-Hello World!
/ Basic Output
/ Adv. Output
-Variables
/ Scalar
/ Arrays
/ Joining Arrays
-File/Directory
/ Opening
/ Saving
/ Modifying
-Subroutines
/ Calling
/ Feeding




|
 |
5.1 - Subroutines / Calling
Subroutines will make your life so much easier once you start implementing them into your code. They allow you to not only seperate different functions from others, but they allow you to call any of the functions whenever you want. Which means it doesn't matter what order all your code is in. You can call a subroutine that's located at the end of your script if you want it to be the first thing executed!
To get you familiar with how subroutines look, I have created some sample code below:
- #!/usr/bin/perl
- print "Content-type: text/html\n\n";
- &getIP;
- &display;
- #Sub GetIP will store your IP in $IP
- sub GetIP {
- $IP = $ENV{'REMOTE_ADDR'};
- }
- #Sub display will now output your IP
- sub display {
- print "Your IP Address: $IP\n";
- }
Checkout Feeding Subroutines to learn howto pass variables to a subroutine from a subroutine call.
Questions? Comments?
Visit Our Web Forums
|
 |

A1Javascripts
A heap of free javascripts to enhance your site!
123Webmaster
The largest directory of free webmaster resources on
the planet!
1-Click-Clipart
The most popular free clip art and web graphic sites on the web!
Free-Clip-Images
A monstrous collection of free graphics including
icons, lines, backgrounds, clip art, animated gifs, and more.
FreeWareFiles
Download tons of FREE Software! Games, Screen Savers,
Utils, and more!
httpCITY
25 megs of free webspace; httpcity.com/YOU!
PerlAccess
Learn perl, or to download free, original perl
scripts.
|
 |