To clarify the Template Toolkit is a web centric tool?

Actually, no. It is a perfectly generic templating system - flexible and extensible. The breadth of the facilities which it offers has been recognised as a benefit by many web application developers and so they have used it for that purpose but it is not web-centric.

Here is your script re-written using TT2, for example:

#!/usr/bin/env perl use strict; use warnings; use Template; my $t = { count => 42, completed => 6 }; my $outtt2 = "\rProcessing: [% count %] files to process ; [% completed %] file c +ompleted\n"; my $template = Template->new; notify_progress (); $t->{completed} = 7; notify_progress (); sub notify_progress { $template->process (\$outtt2, $t); }

I've kept the notify_progress() subroutine so you can see the difference. In a real script this subroutine would disappear and just be replaced by the call to process() inline. If you have a need for templating (and most of us do sooner or later) then do take a look at TT2. It is big and has a steep learning curve compared to others but there are tutorials to help you through and if you use it as I have you will be far less likely to hit a limitation of your templating system than with other, lighter alternatives.


In reply to Re^3: Printing to stdout an array of strings and scalar references by hippo
in thread Printing to stdout an array of strings and scalar references by Anonymous Monk

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.