Log in

View Full Version : Perl question


TheMatrix
April 12th, 2011, 01:01 PM
So.......

I've been trying to use GD::SecurityImage on Perl. Just for a quick test, you know.
I am running it in Ubuntu with LAMPP 1.7.4.

Here is the code:

#!/usr/bin/perl -wT
use GD::SecurityImage;
use CGI;
my $str = int(rand(4598654));
# Create a normal image
my $image = GD::SecurityImage->new(width => 100,
height => 50,
lines => 20,
gd_font => 'giant');
$image->random($str);
$image->create(normal => 'rect');
my($image_data, $mime_type, $random_number) = $image->out;

print CGI->header( "image/$mime_type" );
binmode STDOUT;

print $image_data;

Taken directly from the SYNOPSIS section of the perldoc about this, with a slight modification. I have GD::SecurityImage installed. And here's the strange thing: it runs just fine from the command line, but not in a browser. In the browser it says that it could not find the module. Why is that??

anonymous.john
April 12th, 2011, 09:42 PM
Is your server configured to parse Perl scripts?

TheMatrix
April 14th, 2011, 05:21 PM
Is your server configured to parse Perl scripts?
Yes, it is. LAMPP includes perl, although I have GD installed in the /usr/lib/perl5 or something, so I have to use the Ubuntu Perl interpreter. I've tried to compile the extension using the LAMPP Perl interpreter, but that never worked :(

anonymous.john
April 14th, 2011, 05:33 PM
Okay, I haven't ever used perl, but I have manually configured servers to run custom PHP interpreters. You have to point the server at Perl to run the scripts when they're loaded. I'm not familiar with Perl, but with PHP this is done by setting up *.php as an extension and then having those passed to php at loadtime. If you give me some information about your server I might be able to help. Is it remote or local?

From the error it seems like you have the server pointed at a nonexistent parser/VM and you need to check your paths (again, I don't know how perl works, and I'm assuming your script is valid).