Perl

Scripts ending in .pl will be executed within a Perl CGI handler.

Additional modules

Additional system-wide Perl modules can be installed (by requests sent to saa@uvm.edu) if they are provided by Red Hat. You can find this out by using yum whatprovides.

Example:

1
2
3
4
5
6
yum whatprovides "*/XML/Parser.pm"
Loaded plugins: security
perl-XML-Parser-2.36-7.el6.x86_64 : Perl module for parsing XML files
Repo        : rhel6-x86_64-stage0
Matched from:
Filename    : /usr/lib64/perl5/XML/Parser.pm

Otherwise, it is up to the user to install and manage third-party Perl modules required for an application. SAA will assist upon request if header files or required libraries are missing. A utility such as cpanminus can be very helpful to maintain a local private repository of modules.

You can set up a cpanm environment in ~/perl5 with:

1
2
eval `perl -I ~/perl5/lib/perl5 -Mlocal::lib`
echo 'eval `perl -I ~/perl5/lib/perl5 -Mlocal::lib`' >> ~/.profile

Now you should be able to run cpanm <module> just as you might normally run cpan.

Example application

You can use the Mojolicious framework to create web applications of any size. The Lite version makes small applications particularly easy to create:

1
2
3
4
5
6
#!/usr/bin/perl
use Mojolicious::Lite;

get '/' => { text => 'Hello, world!' };

app->start;

Example basic CGI script

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
#!/usr/bin/perl

print("Content-Type: text/plain\n\n");

foreach $var (sort(keys(%ENV))) {
   $val = $ENV{$var};
   $val =~ s/\n/\\n/g;
   $val =~ s/"/\\"/g;
   print "${var}=\"${val}\"\n";
}