cormanaz has asked for the wisdom of the Perl Monks concerning the following question:
I am told by this place that I can put my module into a special directory and reference it like so:package sqlsupport; use strict; use DBI; require Exporter; our @ISA = qw(Exporter); our @EXPORT_OK = qw(); sub connectdb { my $database = shift; my $driver = "mysql"; my $server = "localhost"; my $url = "DBI:$driver:$database:$server"; my $user = "perl\_interpreter"; my $password = "crawdad"; my $dbh = DBI->connect( $url, $user, $password ) or die "connectdb + can't connect to mysql: $!\n"; return $dbh; } sub dosql { my @results = (); my ($dbh,$sqlstatement,$response)= @_; my $sth = $dbh->prepare($sqlstatement); my @row; $sth->execute || die "Could not execute MySQL statement: $sqlstate +ment"; if ($response) { while (@row=$sth->fetchrow_array) { push(@results, [ @row ]); } } $sth->finish(); return @results; } 1;
When I do that, I get no error on the use statements, but perl says it can find either of the subroutines. I have not gone through the whole make, make build, etc. process because I thought that is only necessary if you are inserting the module into the local lib structure. Maybe not, tho.use lib qw(/myPerl/myModules/); use sqlsupport;
Your advice appreciated.
Steve
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Custom module problems
by davidrw (Prior) on May 02, 2006 at 17:29 UTC | |
Re: Custom module problems
by freddo411 (Chaplain) on May 02, 2006 at 17:52 UTC | |
Re: Custom module problems
by Fletch (Bishop) on May 02, 2006 at 17:40 UTC | |
Re: Custom module problems
by strat (Canon) on May 03, 2006 at 08:39 UTC | |
Re: Custom module problems
by greenFox (Vicar) on May 03, 2006 at 02:49 UTC |