Silk Web Hosting: Perl
ModifiedChoosing a version
You can choose among multiple versions of Perl:
Silk platform | Perl version | Command-line path | Sunset Date |
---|---|---|---|
silkv2 | 5.16 (default) | /usr/bin/perl | |
5.30 | /usr/local/bin/perl530 | ||
silkv3 | 5.38 (default) | /opt/mise/installs/perl/5.38/bin/perl | July 2, 2026 |
If you need to switch Perl versions, you can do so by creating or editing
your site’s .silk.ini
file (for example ~/www-root/.silk.ini
) and adding the
version to the [perl]
section:
[perl]
version = 5.30
Valid version choices are default
, any of the versions listed in the table
above, or newest
(which provides the newest available on the system).
Modules
Perl modules can be installed into
your own repository with the
cpanm
command. SAA will assist upon request if header files or required libraries
are missing.
You can set up a module environment in ~/perl5
with:
$ eval `perl -I ~/perl5/lib/perl5 -Mlocal::lib`
$ echo 'eval `perl -I ~/perl5/lib/perl5 -Mlocal::lib`' >> ~/.profile
Now you can install a module with cpanm <modulename>
.
You can add ~/perl5
to Perl’s @INC
module include path by adding the following line at the top of your script:
use local::lib;
Then you can use
any modules you have installed.
Web applications
Scripts ending in .pl will be executed within a Perl CGI handler.
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:
#!/usr/bin/perl
use Mojolicious::Lite;
get '/' => { text => 'Hello, world!' };
app->start;
Example basic CGI script
#!/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";
}