March 2002 | Perl Hardware Store | 17 |
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->prepare($query) or die "Couldn't prepare '$query': " . $dbh->errmsg;
$sth->execute(...) or die "Couldn't execute '$query': " . $sth->errmsg;
my @data; while (my $rec = $sth->fetchrow_hashref) { push @data, [@$rec]; } $sth->finish;
# Do something with @data
You're sick of repeating the same code over and over
You wish that Msql supported a myquery method:
@data = $dbh->myquery($query, ...); # dies if necessary # Do something with @data
Next | Copyright © 2002 M-J. Dominus |