Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Help with modules!

by hiseldl (Priest)
on Sep 24, 2002 at 13:56 UTC ( [id://200366]=note: print w/replies, xml ) Need Help??


in reply to Help with modules!

If you mean that you need to create your db handle in your program and use it in your module, then you can just pass the handle to your module's new method.
#!/usr/bin/perl -w use DBI; my $dbh = new DBI->connect(...); my $pkg = new MyModule($dbh); ############################################## package MyModule; sub new { my ($dbh) = @_; my $self = (); $self{dbh} = $dbh; ... } sub MyMethod { my ($self) = @_; # use the db handle something like this $self{dbh}->quote(...); ... }

--
hiseldl
"Act better than you feel"

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://200366]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (4)
As of 2024-04-25 13:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found