Back in the bad old days before I started using CGI, I always had my parameters in the form of a hash. That made interpolating into strings easy. Now they come in the form of function calls. So there are lots of different ways to get them into strings, none of them quite right. Here are my least un-favourite three:
(1) my $dbh->do("INSERT INTO tbl VALUES (".param('Col1').",".param('Col2') +.",".param('Col3').")"); (2) my $Col1 = param('Col1'); my $Col2 = param('Col2'); my $Col3 = param('Col3'); my $dbh->do("INSERT INTO tbl VALUES ($Col1,$Col2,$Col3)"); (3) my %params = Vars; my $dbh->do("INSERT INTO tbl VALUES ($params{'Col1'},$params{'Col2'},$ +params{'Col3'}')");
I feel that none of these is the canonical way. (1) is too messy and buggable, whilst (2) and (3) involve seemingly needless proliferation of variables. I'd be very glad to see how the mighty ones do it.

§ George Sherston

In reply to Using CGI.pm params to make a DBI MySQL query by George_Sherston

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.