Please Perlers,

The following script:

<code>
use strict;
use warnings;

my $sql_date = '2014-7-31';

my $raw_string_1 = 'WHERE col = $sql_date';
my $raw_string_2 = '$sql_date';

my $evaled_1 = eval $raw_string_1; # yields 'undef'
my $evaled_2 = eval $raw_string_2; # yields '2014-7-31'

print "First: $evaled_1\nSecond: $evaled_2\n";
</code>

Yields 'undef'  (and a concatenation warning) for $evaled_1 and '2014-7-31'
for $evaled_2. Why???

Notes:
1) I need the first form to work.
2) I am well aware of the DBI/DBD 'prepare()' with place holders. Mine is
not the case for it, since 'col' is a run-time column name and so it cannot
be assigned a place holder.
3) Neither can the date be assigned to a place holder. It is not always a
date. The "WHERE" clause is an arbitrary complex compilation read from an
INI file and various parts in it must be substituted by Perl variables
values, also only determined at run-time.

Thanks!
Meir

_______________________________________________
Perl mailing list
Perl@perl.org.il
http://mail.perl.org.il/mailman/listinfo/perl

Reply via email to