In my opinion, the name
$hashref is not a very descriptive name. Looking at the code, I'd say that
$group_info communicates more clearly the meaning of the data. You retrieve the "org" and "group" data in a single SQL statement, so like
perrin says in
Re: Splitting a hashref into hashrefs, the can be assumed to be related. If not, you should rethink the query, and maybe split them in two parts, after which the template can be as you want it.
If they are related, a renaming of variables can be very helpful:
my $group_info = $slashdb->sqlSelectHashref(
# SELECT
'o.org_id, o.name, g.group_id, g.name',
# FROM
'groups AS g, orgs AS o',
# WHERE
"group_id = $group_id AND o.org_id = g.org_id",
);
Now, the call to
slashDisplay() will be:
slashDisplay('group_edit', { group_info => $group_info });
And the template will look like:
<p>Org id: [% group_info.org_id %]</p>
<p>Org name: [% group_info.org_name %]</p>
<p>Group id: [% group_info.group_id %]</p>
<p>Group name: [% group_info.group_name %]</p>
This way, the code remains simple, and the template is perfectly understandable.
Arjen
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.