Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想对模块进行子类化以使用 C 代码DBI隐藏子例程。connect例如,我有:
DBI
connect
$dbh = DBI->connect($data_source, $username, $auth, \%attr);
我想编写一些调用上述子例程并在 Perl 中DBI->connect返回句柄的 C 代码。$dbh
DBI->connect
$dbh
是否可以这样做,如果可以,有人可以提供一个例子或指出一些来源吗?
为什么是子类?只需创建一个子!
sub my_connect { # Get from config file or whatever my $user = ...; my $passwd = ...; return DBI->connect($data_source, $username, $auth, \%attr); }