perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andr...@switchonline.com.au (Andrew O'Brien)
Subject Re: need help: use my own perl class (pachage or module) in embperl
Date Mon, 16 Sep 2002 03:48:21 GMT
On Sun, Sep 15, 2002 at 10:42:57AM -0700, Sally Li wrote:
> I am a new user of embperl. I am writing a web-based
> application using embperl. Since I have developed some
> classes in perl it will be convenient to reuse them
> for the application development. However, failed due
> to my class. Here is a test. The structure is based on
> the manual example in embperl. The class ConnectDB.pm
> is placed in foo/ dir, same as base.htm.
> 
> Also, I set a path to this dir.
> 
> Could any one tell me where I should put ConnectDB.pm
> (my class)? 

Have a look at the embperl log and/or the apache error log, there
should be a line similar to the following:

Can't locate ConnectDB.pm in @INC (@INC contains: <list of dirs>)

This list of directories is where embperl/perl is looking for your
module. In order to fix this you'll need to tell the webserver
environment where else to look for modules outside the normal system
directories.

I'd recommend creating a startup.pl file and placing all perl
directives in there for Apache to run.

The line:

PerlRequire startup.pl

in your httpd.conf will tell mod_perl to execute startup.pl from the
apache config root (eg /etc/apache)

Heres a quick example startup.pl. Its cut down from our real one but
it should be enough for your purposes. Comment out modules that you're
not using.


#! /usr/bin/perl
# mod_perl init

# $Id: startup.pl,v 1.33 2001/11/16 04:09:51 andrewo Exp andrewo $

# add paths for local modules
use lib qw(
	   /path/to/my/modules
	  );


# load frequently used modules in the parent

#use Apache::DBI; # load Apache::DBI before DBI!
use DBI;
use DBD::Pg; # or whatever DBD module you're using (if any)

use Apache::Session; # load Apache::Session before Embperl!
use HTML::Embperl;
use HTML::EmbperlObject;

use ConnectDB;

# kill -USR1 <spinning httpd PID> for perl stacktrace
use Carp ();
$SIG{'USR2'} = sub {
  Carp::confess("caught SIGUSR2!");
};

1;
__END__



-- 
 Andrew O'Brien
 Senior Engineer                       email: andrewo@switchonline.com.au.
 Switch Online Group Pty Limited       phone: +61 2 9299 1133
 ABN 89 092 286 327                    fax:   +61 2 9299 1134

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Mime
View raw message