First, even though you have already written code to parse a CSV file, i still recommend you use Text::CSV or Text::CSV_XS - maybe DBI::CSV would be very useful for this script.

Second, your kludge on 419 ... trying to encapsulate your database queries into one 'catch-all' subroutine is most likely going to lead to one nasty chunk of code. If you really want to abstract your database layer, try something like Class::DBI. One serious problem you have with that subroutine (execute_mysql_query) is that you connect to the database and disconnect from it each time you call that sub. Better is to connect once at the beginning of the script and store the database handle as a global variable. That subroutine really gains you very little right now, and seems rather hackish.

Third, i would just make $parts_algo a global variable. I like to declare vars that hold the command line arguments with use vars. For a small utility script like this, having your database handle and your options global shouldn't cause any problems ... unless you plan on using this under Apache::Registry (and i should hope not!). As for eval ... i personally don't like to eval just anything that the user can hand me. You should at least verify that the eval comforms to some kind of specification. Also, check the truth value of $@ to see if the eval fails.

Everything else seems fine ... oh yeah! Don't forget to remove you password when you post code online! ;)

Updated node: added a few things.

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

In reply to (jeffa) Re: Code review and question for parts script by jeffa
in thread Code review and question for parts script by bprew

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.