jptxs has asked for the wisdom of the Perl Monks concerning the following question:
craziness:
prints:%hash = ( one => [1,2,3,4,5], two => [a,b,c,d,e], the => [l,m,n,o,p] ); foreach my $key ( keys %hash ) { push @cols, $key; push @vals, scalar( join ",", @{$hash{$key}} ); } foreach $val ( @vals ) { print "$val"; print "\n"; } print "\n"; $statement = 'insert into this (' . (join ",", @cols) . ') values (' . + (join ",", @vals) . ')'; print "$statement\n\n";
yet change the 'the' hash key's value to anything else and:/home/jptxs > perl sortHashForInsert l,p a,b,c,d,e 1,2,3,4,5
craziness!/home/jptxs > perl sortHashForInsert 9,8,7,6,5 a,b,c,d,e 1,2,3,4,5
-- I'm a solipsist, and so is everyone else. (think about it)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
works now under strict : )
by jptxs (Curate) on Oct 11, 2000 at 08:02 UTC | |
|
Re: l
by japhy (Canon) on Oct 11, 2000 at 08:40 UTC | |
|
Re: l
by merlyn (Sage) on Oct 11, 2000 at 08:06 UTC | |
|
Re: l
by Anonymous Monk on Oct 11, 2000 at 19:48 UTC | |