Your First Time
Assuming all has gone to plan, you can now create your first Perl script. Follow these instructions, but before you start read them through once, then begin. That's a good idea with any form of computer-related procedure. So, to begin:
- Create a new directory for your perl scripts, separate to your data files and the perl
installation. For example,
c:\scripts\, which is what I'll assume you are using in this tutorial.
- Start up whatever text editor you're going to hack Perl with. Notepad.Exe is just fine. If you can't find Notepad on your Start menu, press the Start button, then select Run, type in 'notepad' and click OK.
- Type the following in Notepad
print "My first Perl script\n";
- Save the to
c:\scripts\myfirst.pl. Be careful! Notepad will may save files with a
.txtextension, so you will end up with
myfirst.txt.plby default. Perl won't mind, it'll still execute the file. If your version of Notepad does this, select "All files" before saving or rename the file then load it again. Better yet, use a decent text editor!
- You don't need to exit Notepad -- keep it open, as we'll be making changes very soon.
- Switch to your command prompt. If you don't know how to start a command prompt, click 'Start' and then 'Run'. If using Windows 9x, type in 'command' and press enter. If using NT, type in 'cmd' and press Enter.
- Change to your perl scripts directory, for example
- Hold your breath, and execute the script:
and you'll see the output. Welcome to the world of Perl ! See what I mean about it being easy to start ? However, it is difficult to finish with Perl once you begin :-)