Howdy Monks. I have some subroutines I am using a lot so I decided to try to put them into a custom-made module. Here they are:
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;
I am told by this place that I can put my module into a special directory and reference it like so:
use lib qw(/myPerl/myModules/); use sqlsupport;
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.

Your advice appreciated.

Steve


In reply to Custom module problems by cormanaz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.