in reply to l,m,n,o,p special?
got it to work with help from the Chatter crew, but the errors it spit out at first were:
notice it only complains about l and p, the first and last elements of the list on line 6...why??Bareword "a" not allowed while "strict subs" in use at sortHashForInse +rt line 5. Bareword "b" not allowed while "strict subs" in use at sortHashForInse +rt line 5. Bareword "c" not allowed while "strict subs" in use at sortHashForInse +rt line 5. Bareword "d" not allowed while "strict subs" in use at sortHashForInse +rt line 5. Bareword "e" not allowed while "strict subs" in use at sortHashForInse +rt line 5. Bareword "l" not allowed while "strict subs" in use at sortHashForInse +rt line 6. Bareword "p" not allowed while "strict subs" in use at sortHashForInse +rt line 6.
because m,n,o, gets interpreted as m/n/o/ the commas get used as alternative quotes for the match operator 'm'
Perl is too gracious : )
use strict; my %hash = ( one => [qw(1 2 3 4 5)], two => [qw(a b c d e)], the => [qw(l m n o p)] ); my (@cols, @vals); foreach my $key ( keys %hash ) { push @cols, $key; push @vals, scalar( join ",", @{$hash{$key}} ); } foreach my $val ( @vals ) { print "$val"; print "\n"; } print "\n"; my $statement = 'insert into this (' . (join ",", @cols) . ') values ( +' . (join ",", @vals) . ')'; print "$statement\n\n";
-- I'm a solipsist, and so is everyone else. (think about it)
|
|---|