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;

🦛


In reply to Re^5: Here documents in blocks by hippo
in thread Here documents in blocks by Bod

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.