some require pluralisation whilst other don't.
Have you seen Lingua::EN::Inflexion? It allows you to construct a generic pattern (a template of sorts) to handle various cases like this.
If there is a way to simplify it which can be quickly implemented then I would certainly change my approach.
It can be quickly implemented, if not quickly learnt. Because these are modules with which I am familiar I would use Template for the templating system with the Template::Plugin::Lingua::EN::Inflexion plugin which would allow for a simple loop to produce the table contents and proper pluralisation of the prose. TIMTOWTDI, of course.
#!/usr/bin/env perl
use strict;
use warnings;
use Template;
# Set up your data
my $data = {
table => [
{
head => 'Bookings this month',
val => 132,
},
{
head => 'Previous 30 days',
val => 99,
},
{
head => 'Forthcoming 30 days',
val => 150,
},
{
head => 'Forthcoming 60 days',
val => 189,
},
],
event_count => 1,
call_list => 5
};
# Set up your template (easiest/commonest in an external datastore (fi
+le
# or DB)
my $template = <<EOT;
<div style="float:right">
<p class="sectionHead"><b>FHL Properties:</b></p>
<table>
[% FOR k IN table %]
<tr>
<th class="itemHead">[% k.head %]:</th>
<td>[% k.val %] </td>
</tr>
[% END %]
</table>
</div>
<hr style="clear:both">
[% USE infl = Lingua.EN.Inflexion; FILTER inflect; -%]
<p class="sectionHead"><b>Progress in Property Event:</b></p>
<p class="itemHeadLarge"><#:[% event_count %]> <N:person> <V:has> regi
+stered their interest.</p>
<hr>
<p class="sectionHead"><b>Customer Contentment Call List:</b></p>
<p class="itemHeadLarge"><#d:[% call_list %]> There <V:is> [% call_lis
+t %] <N:person> who <V:is> on the Call List.</p>
<hr>
[% END %]
EOT
# Run it
Template->new->process (\$template, $data);
exit;
|