August 1999 | Perl Hardware Store | Slide #18 |
Adding a new Method to a Package
Suppose you're using someone else's package
There's a method you wish it has, but it doesn't
For example:
my $sth = $dbh->query(...); error() unless defined $sth;
my $num_records = $sth->numrows(); for ($i=0; $i<$num_records; $i++) { # Get next record my %data = $sth->fetchhash();
# Do something with %data }
You're sick of repeating the same error-checking code
You wish that Msql supported a myquery method
Next | Copyright © 1998 M-J. Dominus |