Please double check:
- $3 contains something reasonable
- concatenating $3's value and "\n" (by interpolation) is correct ("\n" in field?)
- as ' doesn't interpolate =>
my $st_ht->bind_param(1, $d_var);
(I don't understand the DBI Docs as Chris Ledet does.)
On 2nd thought:
This code snippet:
my $v = "nix nix 1001";
print "$v\n";
print '$v\n', "\n";
if ($v =~ m/(nix) (nix) (\d+)/) {
print 'found: ', $3, "\n";
$sth = $dbh->prepare('SELECT * FROM sample01.csv WHERE GRUPPE=?');
$sth->bind_param(1, $3);
$sth->execute;
while(my @row = $sth->fetchrow_array()) {
print '|', join( '|', @row ), "|\n";
}
} else {
print "no match\n";
}
and the output:
DBI: 1.616 DBD::CSV: 0.33
|00000089-6d83-486d-9ddf-30bbbf722583|2011-09-17 16:25:09|1001|
|000004c9-92c6-4764-b320-b1403276321e|2011-11-09 13:52:30|2000|
nix nix 1001
$v\n
found: 1001
|00000089-6d83-486d-9ddf-30bbbf722583|2011-09-17 16:25:09|1001|
should illustrate:
- ' does not interpolate, your '$d_var' will pass this variable name literally to DBI
- a valid match needs no "\n" to 'work'
- the param sequence for bind_param is number, value
$d_varinbind_param()?die "\$d_var not defined" unless defined $d_var;.$st_h->bind_param(1, '$d_var')