in reply to Best practices for passing $dbh to subroutines
It seems awfully clunky to do it the way I've been doing it (where the first variable passed to any subroutine is the database handler). It works, but this is Perl -- there *must* be a more elegant way of doing it. :)
um, not really :) that is about as elegant as you should get with one variable
If you've got more pass a "hash"
foo( dbh => $dbh, roshambo => 'dynamite'} ); ... sub foo { my %args = @_; $args{dbh}->prepare...; }
chromatics free book Modern Perl talks about this (%parameters)
OTOH, there are things like Sub::NamedParams/Params::Named/Method::Signatures...
|
|---|