PERL - Programming
PERL was designed to be simple and direct. We outlined earlier that file manipulation and grep style functions are the bread and butter of PERL. Often times these types of tasks will require some form of user input. PERL can do exactly that (imagine that) and these next few pages of tutorial will walk you through the process step by step.
PERL - User Input
PERL is capable of quickly taking input from a user then manipulating it in some fashion and spitting out some sort of result. Whether the task at hand is complex file manipulation or just a simple conversion script, your script may require some sort of user-input. With PERL this input comes from the command prompt or MS-DOS on a windows machine.
In a minute we will be taking a look at how to retrieve some user input via the command prompt but first, you may need to install a PERL compiler for your machine.
ActivePERL - PERL for Windows
PERL comes pre-installed on many operating systems, like Linux for example. For those of us running a version of Windows however, we must download and install some sort of program that allows us to access PERL scripts from DOS. There are many PERL compilations available for your machine. A simple Google search yields several million results.
ActivePERL is the simplest of installers available and it is also free to download. Download the program, follow the onscreen installation guide, and you should have an active installation of PERL ready to go.
To test the installation, make sure the program has fully completed installation and then run through the following:
- Click on Start, go to Run.
- Enter Command or cmd into the display box.
- At the command prompt type perl -v.
You should get some documentation about Larry Wall 1987-200X, and that means you are officially done installing PERL and ready to start creating some PERL scripts.
PERL - Testing...Testing Script
Just to be sure everything is running correctly. Open up notepad or your preferred simple text editor and let's make a beginning script. We'll have our script print to the command prompt with the print function just as we would if we were printing text to our web browser.
print "Hello PERL!";
Copy the two lines above and save them in a directory that you are capable of accessing through DOS. Locate that directory in your DOS prompt and simply type the name of your PERL script into the command prompt to execute your script.
Upon execution, the script should print the words "Hello PERL!" at the bottom of your command prompt.
You should now have some basic concept of how to manage and run PERL scripts from the command prompt of your machine. Next we will be taking a look at how to manipulate user input via the command prompt.
Found Something Wrong in this Lesson?
Report a Bug or Comment on This Lesson - Your input is what keeps Tizag improving with time!