Server move broke perl script

Hi all, hoping somebody out there can help with this.

The recent server moves broke the perl script on one of my sites. Unfortunately, I wrote the script a good three years ago as part of an arts-based masters degree project and I have no idea how to follow the brief advice offered by DH to fix it. I was never a programmer to begin with, and I simply don’t have the time to delve back into all this to get my head around it again. I’m not being lazy; I’m just insanely busy with other things at the moment (but would really like this project to continue working).

Here’s what DH said:

Your perlmods directory uses libs from perl 5.8.4 (which was the older
version of perl on your old server), but your new server has perl version
5.8.8. You need to replace those old lib files with new ones for perl
version 5.8.8

Here are my questions:

Where can I download the new lib files? Which files do I need? And can I simply create a 5.8.8 folder in my perlmods/lib/perl directory via FTP and put the files in there?

Here is my script, if that’s relevant:

#!/usr/bin/perl -wT

use strict;
use CGI ‘:standard’;

print “Content-type:text/html\n\n”;

use lib ‘/home/jesskilb/perlmods/share/perl/5.8.4’;
use lib ‘/home/jesskilb/perlmods/lib/perl/5.8.4’;

use File::Random qw/:all/;

my $dir = ‘/home/jesskilb/’;
my $file = random_file(-dir => “$dir/infinity”);
my @lines = random_line("$dir/infinity/$file", int(rand(3)) + 1);
my $randomlines=join("

open(OUTPUT,"$dir/results_template.html") or die “Can’t open file\n”;
my $line;
while ($line=) {
$line=~s/results go here/$randomlines/;
print $line;
close OUTPUT;

and here’s what’s currently in my 5.8.4 directory:


Any help would be MUCH appreciated. Thanks in advance!

You probably ran CPAN sometime before.


Quick overview:

  1. Make sure you set PERL5LIB before running CPAN. Shouldn’t have to say but yeah you should duplicate the 5.8.4 paths so you got both 5.8.4 and 5.8.8 in it just in case its needed.

  2. Ditto for the paths to add to the perl scripts.

  3. When running CPAN it will ask for URLs to use to get modules from. Select about 10 or so. Too few may mean modules can’t be found.

  4. Don’t forget to add PERL5LIB to your .bash_profile in case you need to run CPAN again

Customer since 2000 :cool:

Thanks for taking the time to reply; I really appreciate it. Unfortunately your advice is still way above my head. Can anybody out there provide step-by-step instructions for what I need to do, explained as you would to a 5-year-old? I’ve spent the afternoon trying to Google my way to self-sufficiency on this but I feel ever more stressed and confused than before I started.


Your script requires that one go through hoops just to get it to pick random lines from a random file. We can make it a bit easier by re-factoring it: combine the files into one named “combined_file”

So you replace

my $file = random_file(-dir => "$dir/infinity"); my @lines = random_line("$dir/infinity/$file", int(rand(3)) + 1); with the following

my @lines = random_line("$dir/infinity/combined_file", int(rand(3)) + 1); So that leaves us with reading the file and picking some lines from it.

[code]sub random_line {
my $filepath = shift;
my $count = shift;
my @lines = ();
my @random_lines = ();

read file into memory

open(FILE, $filepath) or die “Can’t open file\n”;
while(my $line = ) {
push(@lines, $line);

quit if there are not enough lines

return unless scalar(@lines) > $count;

pick lines except for empty ones

while ($count > 0) {
my $line = $lines[int(rand(scalar(@lines)))];
next unless length $line > 0;
push(@random_lines, $line);
$count -= 1;
return @random_lines;
Customer since 2000 :cool: