My comments(HM>>) are below.  Sorry for the poor message quoting -
thanks to Groupwise on Windoze XP.

>>> "Robert" <[EMAIL PROTECTED]> 07/29/04 11:51AM >>>
I have seen:

my $sth = $dbh->prepare( <<SQL_END );
SELECT blah
FROM blah
WHERE blah = blah
SQL_END

HM>> I've never used this method but there's no reason it shouldn't
work.  This uses what perl calls "Here Documents" to bound a multi-line
string.

my $sth = $dbh->prepare(q{
SELECT blah
FROM blah
WHERE blah = blah
});

HM>> A single q is the same as using single quotes to surround a
string, except that q{} allows you to put single quotes inside it and
those single quotes won't interfere with the q{} quoting of the whole
string.  Note that a string bounded by single quotes (or q{}) does *NOT*
allow $variables to be interpolated - so if you did:

     my $sth = $dbh->prepare(q{
                 SELECT blah
                FROM blah
               WHERE column1 = $value1
      });

the value of $value1 would *NOT* appear in the SELECT.

my $sth = $dbh->prepare(qq{
SELECT blah
FROM blah
WHERE blah = blah
});

HM>> qq{} is the same as using double quotes to surround a string only
qq{} allows double quotes to appear inside without affected the quoting
of the whole string.  Double quotes *DOES* allow variable
interpolation.

What is the difference? I am new to Perl/DBI stuff.

Robert

HM>> Suggestion - read up on using "Placeholders".  Do

     perldoc DBI

at a command prompt and read the excellent perldocs for the DBI module.
 Placeholders are described in-depth there.  The way I prefer is to use
q{} with placeholders - better performance and no quoting issues :-)

HTH.

Hardy Merrill


Reply via email to