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
In reply to ??Best way to subclass BerkeleyDB by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |