LesleyB has asked for the wisdom of the Perl Monks concerning the following question:

Greetings oh wise ones ...

I'm a bit lost on this problem and not sure where the error actually is.

I have a public private key pair which I have defined in a file thusly

package Keys; require Exporter; @ISA=qw(Exporter); @EXPORT_OK=qw(PUBLIC_KEY PRIVATE_KEY); use warnings; use strict; use constant PUBLIC_KEY => 'public key here'; use constant PRIVATE_KEY => 'private key here'; 1;

I have this outside the server tree structure and have written this code to test loading the keys

#!/usr/bin/perl # use strict; use warnings; use lib "/absolute/path/to/directory/containing/keys/pm/file"; use Keys qw(PRIVATE_KEY PUBLIC_KEY); use CGI; print "Content-Type: text/html\n\n"; print PRIVATE_KEY."\n";

From the command line it works. The header and key are printed out.

When I attempt to run it from a web page I get this error

BEGIN failed--compilation aborted at /var/www/herlug.org.uk/test/recaptcha/challenge/trykeys.pl line 7

which happenes to be the 'use Keys ..;' line

and I go ... ? ...

I'm searching through the CGI docs on the basis this may be a CGI related thing I'm not yet aware of but have not yet found a possible solution.

Of course, I could be heading in completely the wrong direction, so if anyone knows what's up and can explain it to me I'd be very pleased to read it.

Replies are listed 'Best First'.
Re: CGI with a 'user defined' package
by ccn (Vicar) on Oct 24, 2008 at 10:55 UTC

    Are /absolute/path/to/directory/containing/keys/pm/file directory and the .pm itself readable for webserver user?

      Yay!!

      Thank you :)

      The .pm file and its containing directory were group and world readable but the directory containing them wasn't.

      It now works in the browser as well as command line