Template::Utils - Various utility functions for the Template Tookit.
use Template::Utils qw( :all ); my $handler = output_handler($target); my $target = update_hash(\%target, \%params, \%defaults)
The Template::Utils module defines a number of general sub-routines used by the Template Toolkit. These can be called by explicitly prefixing the Template::Utils package name to the sub-routine, or by first importing the functions into the current package by passing the ':subs' or ':all' tagset names to the use Template::Utils line.
Template::Utils
use Template::Utils
Creates a closure which can be called to send output to a particular target. The $target parameter may be an existing CODE ref (the ref is returned), a reference to a GLOB such as \*STDOUT (a closure which print to the GLOB is returned), a reference to an IO::Handle (a closure which calls the handle's print() method is returned) or a reference to a target string (a closure which appends output to the string is returned).
\*STDOUT
The closure returned will print all parameters passed to it, as per print().
open(ERRLOG, "> $errorlog") || die "$errorlog: $!\n"; my $fh = IO::File->new("> $myfile") || die "$myfile: $!\n"; my $h1 = output_handler(\*STDERR); my $h2 = output_handler(\*ERRLOG); my $h3 = output_handler($fh); my $h4 = output_handler(\$mystring); foreach my $h ( $h1, $h2, h3, $h4 ) { &$h("An error has occured...\n"); }
Updates the target hash referenced by the first paramter with values specified in the second. The third parameter may also reference a hash which is used to define the valid keys and default values.
A reference to the target hash ($target) is returned.
Andy Wardley <cre.canon.co.uk>
$Revision: 1.6 $
Copyright (C) 1996-1999 Andy Wardley. All Rights Reserved. Copyright (C) 1998-1999 Canon Research Centre Europe Ltd.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Template
To install Template, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Template
CPAN shell
perl -MCPAN -e shell install Template
For more information on module installation, please visit the detailed CPAN module installation guide.