Next | The Perl Hardware Store | DC.pm Version | 22 |
You wish that $dbh supported a myquery method
Subclassing is a pain in the butt
You may have to change a bunch of code
Cheap solution:
sub DBI::db::myquery { my $dbh = shift; # Just stick the method here return @all_data; }
Now you can say
@list_of_hashes = $dbh->myquery(...);
myquery is inherited by DBI's subclasses just the way you'd want.
Downside: The programmer in the next cubicle might do the same thing
If you add a lot of new methods, consider making a subclass
Another downside: People from those other languages may be appalled
continued...
Next | Copyright © 2003 M. J. Dominus |