in reply to Creating strings with specified names

$sth->execute(@data) or die $dbh->errstr;

You don't have to put quotes around the elements of @data when you use placeholders—DBI does that for you.

Replies are listed 'Best First'.
Re^2: Creating strings with specified names
by pc0019 (Acolyte) on Aug 07, 2008 at 20:52 UTC
    Oops, should have thought of that. Thanks!

    Is what I suggested possible?

      Writing Perl that creates variables with a name specified at run time is pretty easy, but it's generally not a good idea.

      $name = 'foo'; $$name = 'bar'; print "foo = $foo\n"; __END__ foo = bar

      Note that doesn't work if you use strict (which is always a good idea). In that case, you wind up with something like this:

      my $name = 'foo'; { no strict 'refs'; $$name = 'bar'; } print "foo = $main::foo\n";

      See how I still had to use the explicit package name to refer to the variable for printing.

      You can do a lot with eval too.