RE: building module/package
> The only configuration I know is > in /etc/httpd/conf.d/perl Yup, that looks like the one. > put this here? I think it would go right above (or below) the "Alias" line. Rob -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 30, 2003 3:12 PM To: Hanson, Rob Cc: 'Perl Newbies'; [EMAIL PROTECTED] Subject: RE: building module/package my redhat 9 is configured canned w/apache and mod_perl. The only configuration I know is in /etc/httpd/conf.d/perl: Alias /mp /var/www/mp SetHandler perl-script PerlHandler ModPerl::Registry::handler PerlOptions +ParseHeaders Options +ExecCGI put this here? setenv PERL5LIB /path/to/lib > Besides the advice given below, there are a few other things you can do... > > To add the location of the Perl script to the lib path you can use this. > The FindBin module finds your script, then sets $Bin to that location. > > use FindBin qw($Bin); > use lib $Bin; > > Another way to do it is to set the environment variable PERL5LIB to the > location of your home-grown modules. You can set this in the Apache > config > (or .htaccess file) with the setenv command (see Apache docs for more > info, > but I think it is "setenv PERL5LIB /path/to/lib"). > > You could also install it into the "site_perl" directory in your @INC > path, > but you should never put it in the "vendor_perl" directories. > > Of the above options I would recommend using the PERL5LIB env variable. > ...And I would also recommend that the libraries not be put in any > directory > accessable to the web server (unless you have no choice). > > Rob > > > -Original Message----- > From: Daniel Staal [mailto:[EMAIL PROTECTED] > Sent: Tuesday, September 30, 2003 2:39 PM > To: [EMAIL PROTECTED]; Perl Newbies > Subject: Re: building module/package > > > > > --On Monday, September 29, 2003 23:53 -0700 "[EMAIL PROTECTED]" > <[EMAIL PROTECTED]> wrote: > >> -I've sent this to the mod_perl list but there seems to be no >> response. >> >> I got the module working in the current directory executing on the >> command line. But I have a problem calling a module in my mod_perl >> dir using apache on redhat 9. I have a mystuff.pm in the same >> directory as the calling perl program. I got it working running on >> the command line but in apache mod_perl, it can't find the module. > > Ok, I know nothing about mod_perl, but let's see what I can do. > First guess: mod_perl considers that 'the current directory' is > either itself or insecure. (Probably the latter: it is in this > context.) > >> Questions: >> - Where should the mystuff.pm be located in? >> - The only place i know about mod_perl configuration file is: >> /etc/httpd/conf.d/perl.conf. This contains the Alias and Directory >> directive. >> >> Error message: >> Can't locate mystuff.pm in @INC (@INC contains: >> /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 >> /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi >> /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl >> /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi >> /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl >> /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 .) > > Hmm. So it does seem to contain the current directory... (That > would be the '.' at the end.) Doesn't help much: We still don't know > *which* directory is the current directory. > > There are two or three things you could do here. First off, you > could put 'mystuff.pm' in one of the above directories. Don't really > recommend that, it confuses the user on what is written on your end > and what isn't, but it is possible. > > Secondly, you could see if there is a way to add to the @INC array in > mod_perl's config. I would assume so, but I have no clue... > > Third, you could add to @INC in your program file. The best way to > do this is to use the 'use lib' pragma. Syntax: 'use lib "$lib";' > where $lib is any perl expression that can be expanded into the > directory. (That means you can use variables, but only ones that > will have a value without running any of your program code...) Put > that in your program before you 'use' your module. > > To simplify: put 'use lib "/path/to/module";' before 'use module;' in > your main program and it should work. ;-) > >> Any help would be great. >> By the way, I just getting started with perl.
RE: building module/package
my redhat 9 is configured canned w/apache and mod_perl. The only configuration I know is in /etc/httpd/conf.d/perl: Alias /mp /var/www/mp SetHandler perl-script PerlHandler ModPerl::Registry::handler PerlOptions +ParseHeaders Options +ExecCGI put this here? setenv PERL5LIB /path/to/lib > Besides the advice given below, there are a few other things you can do... > > To add the location of the Perl script to the lib path you can use this. > The FindBin module finds your script, then sets $Bin to that location. > > use FindBin qw($Bin); > use lib $Bin; > > Another way to do it is to set the environment variable PERL5LIB to the > location of your home-grown modules. You can set this in the Apache > config > (or .htaccess file) with the setenv command (see Apache docs for more > info, > but I think it is "setenv PERL5LIB /path/to/lib"). > > You could also install it into the "site_perl" directory in your @INC > path, > but you should never put it in the "vendor_perl" directories. > > Of the above options I would recommend using the PERL5LIB env variable. > ...And I would also recommend that the libraries not be put in any > directory > accessable to the web server (unless you have no choice). > > Rob > > > -Original Message- > From: Daniel Staal [mailto:[EMAIL PROTECTED] > Sent: Tuesday, September 30, 2003 2:39 PM > To: [EMAIL PROTECTED]; Perl Newbies > Subject: Re: building module/package > > > > > --On Monday, September 29, 2003 23:53 -0700 "[EMAIL PROTECTED]" > <[EMAIL PROTECTED]> wrote: > >> -I've sent this to the mod_perl list but there seems to be no >> response. >> >> I got the module working in the current directory executing on the >> command line. But I have a problem calling a module in my mod_perl >> dir using apache on redhat 9. I have a mystuff.pm in the same >> directory as the calling perl program. I got it working running on >> the command line but in apache mod_perl, it can't find the module. > > Ok, I know nothing about mod_perl, but let's see what I can do. > First guess: mod_perl considers that 'the current directory' is > either itself or insecure. (Probably the latter: it is in this > context.) > >> Questions: >> - Where should the mystuff.pm be located in? >> - The only place i know about mod_perl configuration file is: >> /etc/httpd/conf.d/perl.conf. This contains the Alias and Directory >> directive. >> >> Error message: >> Can't locate mystuff.pm in @INC (@INC contains: >> /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 >> /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi >> /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl >> /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi >> /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl >> /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 .) > > Hmm. So it does seem to contain the current directory... (That > would be the '.' at the end.) Doesn't help much: We still don't know > *which* directory is the current directory. > > There are two or three things you could do here. First off, you > could put 'mystuff.pm' in one of the above directories. Don't really > recommend that, it confuses the user on what is written on your end > and what isn't, but it is possible. > > Secondly, you could see if there is a way to add to the @INC array in > mod_perl's config. I would assume so, but I have no clue... > > Third, you could add to @INC in your program file. The best way to > do this is to use the 'use lib' pragma. Syntax: 'use lib "$lib";' > where $lib is any perl expression that can be expanded into the > directory. (That means you can use variables, but only ones that > will have a value without running any of your program code...) Put > that in your program before you 'use' your module. > > To simplify: put 'use lib "/path/to/module";' before 'use module;' in > your main program and it should work. ;-) > >> Any help would be great. >> By the way, I just getting started with perl. >> -rkl > > Hey, I haven't even completed my first perl program yet. It just > happens that my first program is best written with three modules... > > Daniel T. Staal > > --- > This email copyright the author. Unless otherwise noted, you > are expressly allowed to retransmit, quote, or otherwise use > the contents for non-commercial purposes. This copyright will > expire 5 years after the author's death, or in 30 years, > whichever is longer, unless such a period is in excess of > local copyright law. > --- > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: building module/package
Thanks for your help. I had tried the use lib "path/to/module"; and use module; but it is still complaining about the use module part. However, I took the easy route but may annoy structured folks, like perl is very structured. I put it in /usr/lib/perl5/5.8.0 It works! Yippee! Perl programming is cryptic anyway, isn't it? Just let the next programmer figure it out. just like, [EMAIL PROTECTED]&(2.3), that suppose to mean something ;) Just to keep on chugging, I'll take it out of there as soon as I can figure it out. I know it's probably a one liner in the httpd.conf file but I have mod_perl folks telling me to read the whole website! oh well, thanks. -rkl > > > --On Monday, September 29, 2003 23:53 -0700 "[EMAIL PROTECTED]" > <[EMAIL PROTECTED]> wrote: > >> -I've sent this to the mod_perl list but there seems to be no >> response. >> >> I got the module working in the current directory executing on the >> command line. But I have a problem calling a module in my mod_perl >> dir using apache on redhat 9. I have a mystuff.pm in the same >> directory as the calling perl program. I got it working running on >> the command line but in apache mod_perl, it can't find the module. > > Ok, I know nothing about mod_perl, but let's see what I can do. > First guess: mod_perl considers that 'the current directory' is > either itself or insecure. (Probably the latter: it is in this > context.) > >> Questions: >> - Where should the mystuff.pm be located in? >> - The only place i know about mod_perl configuration file is: >> /etc/httpd/conf.d/perl.conf. This contains the Alias and Directory >> directive. >> >> Error message: >> Can't locate mystuff.pm in @INC (@INC contains: >> /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 >> /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi >> /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl >> /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi >> /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl >> /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 .) > > Hmm. So it does seem to contain the current directory... (That > would be the '.' at the end.) Doesn't help much: We still don't know > *which* directory is the current directory. > > There are two or three things you could do here. First off, you > could put 'mystuff.pm' in one of the above directories. Don't really > recommend that, it confuses the user on what is written on your end > and what isn't, but it is possible. > > Secondly, you could see if there is a way to add to the @INC array in > mod_perl's config. I would assume so, but I have no clue... > > Third, you could add to @INC in your program file. The best way to > do this is to use the 'use lib' pragma. Syntax: 'use lib "$lib";' > where $lib is any perl expression that can be expanded into the > directory. (That means you can use variables, but only ones that > will have a value without running any of your program code...) Put > that in your program before you 'use' your module. > > To simplify: put 'use lib "/path/to/module";' before 'use module;' in > your main program and it should work. ;-) > >> Any help would be great. >> By the way, I just getting started with perl. >> -rkl > > Hey, I haven't even completed my first perl program yet. It just > happens that my first program is best written with three modules... > > Daniel T. Staal > > --- > This email copyright the author. Unless otherwise noted, you > are expressly allowed to retransmit, quote, or otherwise use > the contents for non-commercial purposes. This copyright will > expire 5 years after the author's death, or in 30 years, > whichever is longer, unless such a period is in excess of > local copyright law. > --- > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: building module/package
Besides the advice given below, there are a few other things you can do... To add the location of the Perl script to the lib path you can use this. The FindBin module finds your script, then sets $Bin to that location. use FindBin qw($Bin); use lib $Bin; Another way to do it is to set the environment variable PERL5LIB to the location of your home-grown modules. You can set this in the Apache config (or .htaccess file) with the setenv command (see Apache docs for more info, but I think it is "setenv PERL5LIB /path/to/lib"). You could also install it into the "site_perl" directory in your @INC path, but you should never put it in the "vendor_perl" directories. Of the above options I would recommend using the PERL5LIB env variable. ...And I would also recommend that the libraries not be put in any directory accessable to the web server (unless you have no choice). Rob -Original Message- From: Daniel Staal [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 30, 2003 2:39 PM To: [EMAIL PROTECTED]; Perl Newbies Subject: Re: building module/package --On Monday, September 29, 2003 23:53 -0700 "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > -I've sent this to the mod_perl list but there seems to be no > response. > > I got the module working in the current directory executing on the > command line. But I have a problem calling a module in my mod_perl > dir using apache on redhat 9. I have a mystuff.pm in the same > directory as the calling perl program. I got it working running on > the command line but in apache mod_perl, it can't find the module. Ok, I know nothing about mod_perl, but let's see what I can do. First guess: mod_perl considers that 'the current directory' is either itself or insecure. (Probably the latter: it is in this context.) > Questions: > - Where should the mystuff.pm be located in? > - The only place i know about mod_perl configuration file is: > /etc/httpd/conf.d/perl.conf. This contains the Alias and Directory > directive. > > Error message: > Can't locate mystuff.pm in @INC (@INC contains: > /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 > /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi > /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl > /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi > /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl > /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 .) Hmm. So it does seem to contain the current directory... (That would be the '.' at the end.) Doesn't help much: We still don't know *which* directory is the current directory. There are two or three things you could do here. First off, you could put 'mystuff.pm' in one of the above directories. Don't really recommend that, it confuses the user on what is written on your end and what isn't, but it is possible. Secondly, you could see if there is a way to add to the @INC array in mod_perl's config. I would assume so, but I have no clue... Third, you could add to @INC in your program file. The best way to do this is to use the 'use lib' pragma. Syntax: 'use lib "$lib";' where $lib is any perl expression that can be expanded into the directory. (That means you can use variables, but only ones that will have a value without running any of your program code...) Put that in your program before you 'use' your module. To simplify: put 'use lib "/path/to/module";' before 'use module;' in your main program and it should work. ;-) > Any help would be great. > By the way, I just getting started with perl. > -rkl Hey, I haven't even completed my first perl program yet. It just happens that my first program is best written with three modules... Daniel T. Staal --- This email copyright the author. Unless otherwise noted, you are expressly allowed to retransmit, quote, or otherwise use the contents for non-commercial purposes. This copyright will expire 5 years after the author's death, or in 30 years, whichever is longer, unless such a period is in excess of local copyright law. --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: building module/package
--On Monday, September 29, 2003 23:53 -0700 "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: -I've sent this to the mod_perl list but there seems to be no response. I got the module working in the current directory executing on the command line. But I have a problem calling a module in my mod_perl dir using apache on redhat 9. I have a mystuff.pm in the same directory as the calling perl program. I got it working running on the command line but in apache mod_perl, it can't find the module. Ok, I know nothing about mod_perl, but let's see what I can do. First guess: mod_perl considers that 'the current directory' is either itself or insecure. (Probably the latter: it is in this context.) Questions: - Where should the mystuff.pm be located in? - The only place i know about mod_perl configuration file is: /etc/httpd/conf.d/perl.conf. This contains the Alias and Directory directive. Error message: Can't locate mystuff.pm in @INC (@INC contains: /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 .) Hmm. So it does seem to contain the current directory... (That would be the '.' at the end.) Doesn't help much: We still don't know *which* directory is the current directory. There are two or three things you could do here. First off, you could put 'mystuff.pm' in one of the above directories. Don't really recommend that, it confuses the user on what is written on your end and what isn't, but it is possible. Secondly, you could see if there is a way to add to the @INC array in mod_perl's config. I would assume so, but I have no clue... Third, you could add to @INC in your program file. The best way to do this is to use the 'use lib' pragma. Syntax: 'use lib "$lib";' where $lib is any perl expression that can be expanded into the directory. (That means you can use variables, but only ones that will have a value without running any of your program code...) Put that in your program before you 'use' your module. To simplify: put 'use lib "/path/to/module";' before 'use module;' in your main program and it should work. ;-) Any help would be great. By the way, I just getting started with perl. -rkl Hey, I haven't even completed my first perl program yet. It just happens that my first program is best written with three modules... Daniel T. Staal --- This email copyright the author. Unless otherwise noted, you are expressly allowed to retransmit, quote, or otherwise use the contents for non-commercial purposes. This copyright will expire 5 years after the author's death, or in 30 years, whichever is longer, unless such a period is in excess of local copyright law. --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: building module/package
Daniel: -I've sent this to the mod_perl list but there seems to be no response. I got the module working in the current directory executing on the command line. But I have a problem calling a module in my mod_perl dir using apache on redhat 9. I have a mystuff.pm in the same directory as the calling perl program. I got it working running on the command line but in apache mod_perl, it can't find the module. Questions: - Where should the mystuff.pm be located in? - The only place i know about mod_perl configuration file is: /etc/httpd/conf.d/perl.conf. This contains the Alias and Directory directive. Error message: Can't locate mystuff.pm in @INC (@INC contains: /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 .) Any help would be great. By the way, I just getting started with perl. -rkl > > > --On Monday, September 29, 2003 19:04 -0700 "[EMAIL PROTECTED]" > <[EMAIL PROTECTED]> wrote: > >> test.pl >> --- >> use mystuff; >> >> print mystuff::trim($username); >> >> mystuff.pm >> -- >># do i need any declaration line here >># is sub here or what? >># and where do i put this pm file? >> >> sub trim >> { my $z = $_[0]; >> $z =~ s/^\s+//; >> $z =~ s/\s+$//; >> return $z; >> } > > You're almost good. Add '1;' to the end of mystuff.pm, just to > return a true value when it compiles, and 'package mystuff;' to the > beginning of the same so Perl knows it is a package. Also 'use > warnings' and 'use strict' would be good in both... > > As for where you put it: wherever you want. Just make sure that it > gets included in the @INC path. The easiest is in the same folder as > test.pl (assuming you always run test.pl from there), since the > current folder is in the path. > > Daniel T. Staal > > --- > This email copyright the author. Unless otherwise noted, you > are expressly allowed to retransmit, quote, or otherwise use > the contents for non-commercial purposes. This copyright will > expire 5 years after the author's death, or in 30 years, > whichever is longer, unless such a period is in excess of > local copyright law. > --- > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: building module/package
--On Monday, September 29, 2003 19:04 -0700 "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: test.pl --- use mystuff; print mystuff::trim($username); mystuff.pm -- # do i need any declaration line here # is sub here or what? # and where do i put this pm file? sub trim { my $z = $_[0]; $z =~ s/^\s+//; $z =~ s/\s+$//; return $z; } You're almost good. Add '1;' to the end of mystuff.pm, just to return a true value when it compiles, and 'package mystuff;' to the beginning of the same so Perl knows it is a package. Also 'use warnings' and 'use strict' would be good in both... As for where you put it: wherever you want. Just make sure that it gets included in the @INC path. The easiest is in the same folder as test.pl (assuming you always run test.pl from there), since the current folder is in the path. Daniel T. Staal --- This email copyright the author. Unless otherwise noted, you are expressly allowed to retransmit, quote, or otherwise use the contents for non-commercial purposes. This copyright will expire 5 years after the author's death, or in 30 years, whichever is longer, unless such a period is in excess of local copyright law. --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]