I think you're wrong about your cleanliness assesment.

I think it will be cleaner to pass them a DB handle, because then they don't care what DB they're operating on, and if the main code changes it so that 2 of them use one DB and 3 use another, you only have to change the main program. in short, think of the modules as "doing stuff to a database" rather than "doing stuff to database X", and think of main as "calling the modules on database X" -- because a different main could then use those same modules on a different database.

.

update: yes, but are they also passed what type of DB it is? it is perhaps better to pass them handles, so that one can use a BerkeleyDB and another use DBD::CSV ... and yes, you can pass that information, too, but a handle sums it all up, doesn't it?

that's my take, anyway.

.

In reply to Re: Using DBI handle in several packages by Vynce
in thread Using DBI handle in several packages by Beatnik

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.