Can you post more code, ideally a minimal program that runs, but experiences the problem you're asking about? (There's also a good chance that you'll find the answer yourself in the course of creating such a minimal example.)

The little bit that you've already posted looks correct, so I'm fairly sure your problem is in the code you haven't posted.

The only other thing I can see is that, whenever DBI complains about the absence of an explicit disconnect, it means your handle is going out of scope and being destroyed before you call $conn->disconnect, which is somewhat unsafe. You should always call disconnect when you're done with the database handle. This warning is likely coming when the main program exits (since that's where you're originally setting up $conn) and has nothing to do with the sub, though.


In reply to Re: Passing a DBI handler the proper way by dsheroh
in thread Passing a DBI handler the proper way by gchatelier

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.