in reply to basic dbi question
If you find yourself repeating yourself repeating yourself too much too much, you can also cobble-together a little sub vaguely like this one:
... or whatever else you want to put in there. This is “strictly shorthand,” but sometimes shorthand is what you really want. If you find yourself doing the same thing over and over and over again, put it into a local sub.sub prepare_execute { # (sql, what) my ($sql, $what) = @_; my $sth=$dbh->prepare($sql) # '$dbh' IS GLOBAL... or die "can't prepare $what: $dbh->errstr"; $sth->execute or die "can't execute $what: $sth->errstr"; return $sth; }
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: basic dbi question
by Anonymous Monk on Dec 01, 2010 at 22:41 UTC |