Like the others here I sometimes decalre a database handle as a global, it is perfectly valid to do so.
On the other hand, I think it is far more elegant and easier to 'self-document' your code if you pass the handle into the sub. I got caught big time just a few days ago. I was using the $dbh as a global, then I realised that I needed to connect to a second database on another machine to get some data. To avoid duplicating the database subs I went back and passed the handle in to the subs so I didn't have a maintenanace nightmare.
It only takes one line of code (maybe only a part of a line!) per subroutine, but for me it has been a lifesaver when I do it, and the one time I don;t do it - I get caught!
As always, YMMV & TIMTOWTDI, good luck!
In reply to Re: Is this Bad form? (DBI)
by jdtoronto
in thread Is this Bad form? (DBI)
by Grygonos
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |