Sunday, June 13, 2010

* How can I compile Perl

To compile Perl you need a C compiler on your machine. If your vendor did not include one with your system, then grab a binary version of gcc from the net,

check,
+ http://www.perl.com/pub/language/info/software.html#binary
+ http://www.perl.com/CPAN/ports/

If you are on a UNIX its probably best to compile Perl yourself from the source code distribution. If you are on Windows or MacOS, you will probably be best with a binary build.

* Perl scripting basics

If you are looking to understand a perl script, then these are common elements you may find,
+ # - comment and this line wont get executed.
+ $ - indicates that this is a variable
+ & - if a word starts with a & it is a call to a sub-routine
+ < - the file is being opened for a read operation + > - the file is being opened for a write operation
+ >> - the file is being opened for an append operation
+ (.) - this puts together two variables
+ @ - if a word start with this character it indicates a single-dimension array
+ % - if a word starting with this character indicates a two-dimensional array.
* Perl versions

Version 4
+ was the fourth major release (March 1991)
+ it's stable but,
+ is old, limited, and no longer maintained;
+ its last patch (4.036) was in 1992

Version 5
+ name for the fifth major release (October 1994)
+ rewrite of the original perl source code from releases 1 through 4
+ has been modularized, object-oriented, tweaked, trimmed, and optimized
+ interface is mostly the same

Version 6
+ rewrite of the current release of Perl by the Topaz project
+ 100% source-compatibility with previous releases
+ written in nominally portable C++

* Reporting Perl bugs

If you are reporting a bug in the perl interpreter or the modules shipped with Perl, email Perl at this address,
+ perlbug@perl.com

If you are posting a bug with a non-standard port, a binary distribution, or a non-standard module then you will need to check the documentation that came with it to determine the correct place to post bugs.

* How to start a cgi script with Perl interpreter

Most web servers require this line at the start of any cgi script that uses a perl interpreter,
+ #!/usr/local/bin/perl (often the Perl 5 location) , or this,
+ #!/usr/bin/perl (often the Perl 4 location)

If this causes an error then asked your web host for it's perl compiler path details.

* Basic Perl Script

To test your ability to store and run a Perl program, enter and execute something like this,


#!/usr/local/bin/perl -w
if ($#ARGV >= 0) { $who = join(' ', @ARGV); }
else { $who = 'World'; }
print "Hello, $who!\n";

this should print "Hello" on your screen.

* How to make your Perl CGI script more efficient

Each time a GCI script runs it will need to be re-compiled by Perl and will often allocate a megabyte or more of system memory, this can be a killer.

There are two popular ways to avoid this overhead.
1. One is running the Apache HTTP server with either of the mod_perl or mod_fastcgi plugin modules.
2. Two running it with the FCGI module (from CPAN) and the mod_fastcgi module (available from http://www.fastcgi.com/) each of your Perl programs becomes a permanent CGI daemon process.

These solutions can both effect your system and how you write your CGI programs, so investigate how them carefully.

Source: www.internet-guide.co.uk

0 comments: