in reply to (MeowChow) Re: DBIx::PearDSN
in thread DBIx::PearDSN
You did, however, hit on one of my pet peeves, which is to place a nontrivial, static data structure definition in the body of a subroutine (my %map in sub dsi_dsn). I would turn %map into a file-scoped lexical, or create a new enclosing scope to contain it outside of dsi_dsn.
I always try to scope such mapping hashes to the subs that need them. Only dsi_dsn needs the %map, so why make it available to other subs? There's also no point in having it global. When configurability is a goal, I make file-scoped lexicals and put those just after the globals, but this is merely a translation map, not something that should be configurable or available to other subs.
It has the look of good code.
Ouch. Most has been directly translated from PEAR's DB.php file (not because I like the code, but because I want to parse it in a similar manner for greater compatibility) - but I replaced most of the pos() and substr() ugliness by splits :)
U28geW91IGNhbiBhbGwgcm90MTMgY
W5kIHBhY2soKS4gQnV0IGRvIHlvdS
ByZWNvZ25pc2UgQmFzZTY0IHdoZW4
geW91IHNlZSBpdD8gIC0tIEp1ZXJk
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(MeowChow) Re3: DBIx::PearDSN
by MeowChow (Vicar) on Apr 08, 2002 at 19:58 UTC |