Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I want to add some of my own functions to a BerkeleyDB object. i.e. use 'connect' to include all my favorite configurations to initialize a BerkeleyDB and some other functions to some specific data sources. i.e.
my $db_obj = MyApp::BerkeleyDB->connect("dbname.db"); .... # then I can use BerkeleyDB internal methods $db_obj->db_put('key', 'value'); .... # use my own functions.. $db_obj->myfunc("src", ...); ....
I guess subclassing is the best way to do this. but I am not an OO-guy so far, and not sure how to handle it. trying $class->SUPER is not working. (Apparently, I dont know how to subclass yet:(((). Can anyone help me or give me a hint on this issue, many thanks
package Myapp::BerkeleyDB use warnings; use strict; use base 'BerkeleyDB'; use BerkeleyDB; # the following code apparently not working!!! sub connect { my ($class, $dbname) = @_; return new BerkeleyDB::Btree -Filename => $dbname, ...... or undef; }
ttg
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: ??Best way to subclass BerkeleyDB
by Corion (Patriarch) on Jul 17, 2008 at 20:01 UTC | |
|
Re: ??Best way to subclass BerkeleyDB
by Joost (Canon) on Jul 17, 2008 at 20:03 UTC | |
|
Re: ??Best way to subclass BerkeleyDB
by moritz (Cardinal) on Jul 17, 2008 at 20:08 UTC |