in reply to Proper Syntax for DBI multiple row insert
The x operator does not work that way. Consider this:
#!/bin/env perl use strict; use warnings; use Data::Dumper; my @records = ( ['value1', 'value2'], ['value3', 'value4'], ['value5', + 'value6']); my @broken = ('( ?, ? )' x @records); print 'broken: ', Dumper \@broken; my @fixed = ('( ?, ? )') x @records; print 'fixed: ', Dumper \@fixed; __DATA__ broken: $VAR1 = [ '( ?, ? )( ?, ? )( ?, ? )' ]; fixed: $VAR1 = [ '( ?, ? )', '( ?, ? )', '( ?, ? )' ];
This example leads us to the corrected line of your original code:
my $values = join ", ", ("( ?, ? )") x @records;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Proper Syntax for DBI multiple row insert
by Rodster001 (Pilgrim) on Dec 22, 2015 at 03:33 UTC |