Keep It Simple, Stupid | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I'm an advocate of DRY, passing it around increases the error probability , e.g. typos.
OTOH globals tend to have a problem, if the line distance between creation and usage gets to big, or generally if scope and context are not easy to oversee. I'd use a block scope to simulate an object², the "global" is used like a class-attribute.
Closures are in most simple cases more elegant than objects, especially in perl¹! (they just can't inherit, but that's not a "simple" case anymore).
Cheers Rolf UPDATES: (¹) just compare to grandfathers lightweight object! No blessing, no $self ... (²) "encapsulation" to be more precise In reply to Re: DBI, $dbh, and subroutines
by LanX
|
|