Constructions like that can often be simplified by slices or by map. In the case of @years and @years_loop in the last example, the for(){push} construction is unnecessary. You already have a list of that data in the parens - just assign it directly. @years_loop is then an easy map,
my $curr_year = (localtime)[5] + 1900;
my @years = $cur_year - 100 .. $cur_year - 5;
my @years_loop = map { { year => $_ } } @years;
$template->param(years_loop => \@years_loop);
The inner pair of curlies in the
map produce a reference to an anonymous hash without needing to give it any temporary name.
After Compline,
Zaxo
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.