|
The first line of every PERL script is a commented line directed toward the interpreter.
firstperlscript.pl:
#!/usr/bin/perl
Lets start with a simple script to print " Hello World "
Example:
#!/usr/bin/perl print "Hello World"
Save it as " firstperlscript.pl ".
In Unix / Linux you will need to give execute permissions for your scripts.
Examples:
$ chmod +x firstshellscript.pl
or
$ chmod 755 firstshellscript.pl
How to run the PERL script:
In Unix / Linux / Windows
perl firstshellscript.pl
Now lets try the same example in the web environment.
We need to add the http headers so that Perl understands we are working with a web browser.
Example:
#!/usr/bin/perl print "content-type: text/html \n\n"; print "Hello World!";
How to run the above script in web environment:
You need to upload the firstperlscript.pl file to your hosting account via FTP.
Chmod it to 755 and access this file using browser.
If everything is fine, the browser should displays " Hello World ". |