Click to See Complete Forum and Search --> : Perl Module Problem!!!


cdavis1986
10-10-2008, 03:03 PM
Hello! I'm trying to write a very small and basic perl module and I cannot get it to work and cannot figure out why. It's a problem with exporting functions from the module, and it refuses to work. When I run the perl script it just stops compiling right when it hits that function. Any help or ideas would be greatly appreciated!!!

Code is as follows:

MODULE(on server):

package SayHello;

use strict;
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT_OK = ("hello_message");

our $VERSION=0.10;
my $hello_string="Hello World!";

sub hello_message {
return $hello_string;
}

1;

***************************************
Script (Client-Side):

#!c:/perl/bin -w
use strict;
use DynaxMod::SayHello;
use DynaxMod::SayHello ("hello_message");


print'
<html>
<head>
<title>diofj</TITLE>
</head>
<body>
';

print hello_message();

print'
</body>
</html>
';

Jeff Mott
10-10-2008, 03:23 PM
In your module, your line

package SayHello;

will almost certainly need to be

package DynaxMod::SayHello;

since that is how you're calling it later.

You'll also have to be much more clear when you say that your second script is running on the client-side, because that's extremely unlikely... or if it is indeed set up that way, then that's also a problem. Your second script should be running on the server with the module.

cdavis1986
10-10-2008, 03:39 PM
Yay! It worked! Yeah, they're both running on the server, I have no idea why I said that. Thank you so much!!!! It's always something small that I get caught on...

:D