--- In perl-beginner%40yahoogroups.com">perl-beginner
yahoogroups.com, essential quint
<quintessential1
...> wrote:
>
>
> Well, I would put them into a module, like the subject line to your
email suggests.
>
> First, create a modules directory, and then in your script create a
module call. You have to use two module for this:
>
> use lib '/home/ete.etc.etc./modules';use db_mod;
>
> You can use the 'pwd' unix command to get an accurate lib path; the
name of your module must go beneath it.
>
> Next build your module. Here's a module template:
>
> package db_mod;require Exporter;
ISA = qw(Exporter);
EXPORT =
qw($dbh, $url, say_hey);
EXPORT_OK = qw();use strict;use CGI;use
CGI::Carp qw(warningsToBrowser fatalsToBrowser);
>
> our $dbh =
DBI->connect('DBI:mysql:insert_db_name:localhost','insert_username','insert_password');
>
> our $url = 'www.whatever.com';
>
> sub say_hey { print "Hello World!n"; }
>
> 1;
> A few notes on the module (in no particular order). 1.) The
EXPORT
line must list all the variables and subs you wish to export, 2.)
CHMOD it to 644, as it doesnt need to be executable, just readable;
3.) The CGI::Carp line is in there only for development purposes, so
take it out when you have finished your app; 4.) the package line
contains the name of the module, which must be reflected in the
script; 5.) The module must end with a 1, i.e. it must return a 1
value, or it will fail.
>
> You should protect your modules directory with an .htaccess file.
The following code works:
>
> <FilesMatch ".pm$">Order deny,allow Deny from all</FilesMatch>
>
> Just c&p it into a notepad file, title it .htaccess and upload it.
>
> There may be some typos in the above scripts, as I just woke up, but
I think they should work.
>
> Good luck.
> HTH,
>
> q
>
Thanks for such a comprehensive and helful reply.
.