JDT |
FREE Downloads |
|
Create and Run a Simple Perl Script |
||||
|
In this tutoral we will look at how to create and run a very simple Perl script. Writing the scriptOpen a text editor, for example, NotePad, and enter the following lines of code: #!/usr/bin/perl The line beginning with #! is the shebang (in Unix) line, and needs to be the first line in the script. It defines the path name where the Perl Interpreter is installed. If you are using Windows, you can omit this line if you want - the script will still run fine. The second line simply prints (on the screen) the message 'Goodbye cruel world'. Save the file as goodbye.pl. You could probably get away without adding the .pl extension to the filename, but I always add it to identify such files as Perl scripts. Make a note of the directory/folder where you have saved the file. Running the scriptYou need to run the script from a command line prompt, so open a terminal window/MS-DOS prompt. Change to the directory/folder where the goodbye.pl file is located, and type the following command: perl goodbye.pl Hopefully, you will see the message 'Goodbye cruel world' displayed on the screen. If you don't, then there is a problem - either with the script itself, or with the execution of the script. Error messagesIf the script did not work, you probably received one of the following error messages:
Author: Backrubber Go back to Perl Tutorials home page Go back to Tutorials home page
|
|