in reply to Re: (jeffa) Re: Converting Python to Perl and back again
in thread Converting Python to Perl and back again
Now then, as for populating these datastructures from a database ... well, i can't help you much with Python. You'll have to read the docs, but i can say that Perl's DBI has methods that will form these datastructures for you, methods such as:genesis['Foxtrot'][0]['instrumental'] = 'excellent' $gensis->{Foxtrot}[0]{instrumental} = 'excellent';
This is very useful with HTML::Template, though i can't help but feel i am re-inventing a wheel. At any rate, i wish you the best of luck. :)# takes prepared statement handle and returns LoH sub db2tmpl { my ($sth) = @_; $sth->execute; my $fields = $sth->{NAME}; my $rows = $sth->fetchall_arrayref; my @loh; for my $row (@$rows) { my %hash; @hash{@$fields} = @$row; push @loh, {%hash}; } return \@loh; }
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (jeffa) 3Re: Converting Python to Perl and back again
by Anonymous Monk on Apr 04, 2003 at 19:50 UTC |