Archive for the tag 'Perl'

SBDavid

Using Variables in Perl

Using Variables in Perl

$_, the default variable. Creating containers for variables in Perl is easy. Give the container a name (which is made up of a combination of the letters A-Z, a-z, the digits 0-9 and the underscore character), then precede the name with one of Perl’s special variable naming characters, depending on what the variable will be used for:

$ – a scalar variable (one of something);
@ – an array variable (a collection of somethings, a list);

% – a hash variable (a collection of name/value pairs); and
\ – a referenced variable (a ‘pointer’ to something else, usually another variable).

SBDavid

Comprehensive Perl Archive Network

The CPAN is the Comprehensive Perl Archive Network and can be accessed at http://www.cpan.org/ , and searched at http://search.cpan.org/ .

# perl -MCPAN -e shell

First, are you sure that the module isn’t already on your system? Try “perl -MFoo -e 1″. (Replace “Foo” with the name of the module; for instance.

“perl -MCGI::Carp -e 1″

If you don’t see an error message, you have the module. (If you do see an error message, it’s still possible you have the module, but that it’s not in your path, which you can display with “perl -e “print qq(@INC)”".)

Integration and Digest::MD5 Perl module

The Digest::MD5 Perl module is no longer bundled with the cPanel and WHM application suite. Existing applications and cPAddons that rely upon this Perl module being provided by cPanel will not function properly after upgrading to cPanel™ 11.25.0.

Developers can address this change in one of two ways:

1. Use the md5_fallback.pm functionality provided in the OSCommerce cPAddon.

2. Bundle the Digest::Perl::MD5 Perl module with their application.

PCRE - Perl Compatible Regular Expressions on Cpanel Servers.

The PCRE library is a set of functions that implement regular expression pattern matching using the same syntax and semantics as Perl 5.

The latest release of the PCRE library is 8.10. You can download it from its official home via anonymous FTP:

ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/

ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.10.tar.gz

tar xvzf pcre-8.10.tar.gz
cd pcre-8.10
./configure
make
make install

More at the man page - http://www.pcre.org/pcre.txt

How to check if Perl script engine is enabled and working for a domain?

To check this we can use a simple script like this:

#!/usr/bin/perl
print “content-type:text/html\n\n”;
print “<html>\n”;
print “<head />\n”;
print “<body>\n”;
print “Hello World!\n”;
print “</body>\n”;
print “</html>\n”;
#

Save the content into a text file and save in the domain web-accessible folder (like $HTTPD_VHOSTS_D/domain.tld/httpdocs) on the server with .pl extension (test.pl for example). Then try to open the file via browser by the http://domain.tld/test.pl URL. The domain name should be resolved for this to work.

The test looks successful if a page shows the “Hello World!” string.

If an error or full script listing is visible, it means that Perl script engine is not configured for the domain properly.

Next »