The only other idea I have uses a list reference and a hash slice with bind_columns. I haven't tested this with DBI, but I did test it standalone.
#!/usr/bin/perl -w
use strict;
my %h;
my @cols = qw( one two three four );
@h{@cols} = ( 1 .. 4 );
assign( \( @h{ @cols } ) );
print "$_ => $h{$_}\n" foreach @cols;
sub assign {
my $val = 0;
foreach (@_) {
$$_ = $val++;
}
}
There. You name your variables only once (outside of the template section), bind them to columns for speed, and are able to access them via a hash lookup. No symbolic references, and the only ugly construct is making a list of references from a hash slice. That beats the
map stuff in my book, and it looks like a spaceship. You can't go wrong there.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.