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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |