Results looked like this#!/usr/bin/perl5.14.1 use DBI; use Data::Dumper; $dbh = DBI->connect("DBI:host", 'name', 'pw', { RaiseError => 1, AutoCommit => 1 }, ); @tesxt = ('perl','python','pearl', 'pear', 'pink', 'pong'); @array1 = ('fan','friend','fang', 'fun', 'food', 'flow'); @array2 = (21,22,23,14, 15, 16); @array3 = ('oh','orange','okay','ostrich', 'open', 'osaka'); @jumpjump= ($tesxt[0], $tesxt[2], $tesxt[3], 'kit','kat',7); push (@data, \@tesxt); push (@data, \@jumpjump); push (@data, \@array1); push (@data, \@array2); push (@data, \@array3); splice (@jumpjump); @jumpjump= ($tesxt[0], $tesxt[2], $tesxt[3], 'koo','kaa',7); push (@data, \@jumpjump); print Dumper \@data; $sth = $dbh->prepare("insert into table_test (just, random, field, for +, testing, purposes) values (?, ?, ?, ?, ?, ?)"); $dbh->begin_work(); foreach my $row (@data) { $sth->execute(@$row); } $dbh->commit(); $dbh->disconnect;
I have no idea where the last $VAR1->1 came from , and I noticed how the @jumpjump being replaced, since I have array with the same name, tho I splice it before putting new values in it, still it's being replace in the big @data array.$VAR1 = [ [ 'perl', 'python', 'pearl', 'pear', 'pink', 'pong' ], [ 'perl', 'pearl', 'pear', 'koo', 'kaa', 7 ], [ 'fan', 'friend', 'fang', 'fun', 'food', 'flow' ], [ 21, 22, 23, 14, 15, 16 ], [ 'oh', 'orange', 'okay', 'ostrich', 'open', 'osaka' ], $VAR1->[1] ];
Anyone has any idea?
I wish to get both the different @jumpjump in the db.***I apologized for not putting using strict here, it's a quick and dirty code that get me started, it compiled, i promise. :)
In reply to Re: Push array into array of arrays
by Anonymous Monk
in thread Push array into array of arrays
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |