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