Tie::Formatted is a Perl module embed sprintf() formatting in regular print().
SYNOPSIS
use Tie::Formatted;
print "The value is $format{$number, "="} ",
"(or $format{$number, "x"} in hex)n";
print "some numbers: $format{ 12, 492, 1, 8753, "d"}n";
This module creates a global read-only hash, %format, for formatting data items with standard sprintf format specifications. Since it's a hash, you can interpolate it into strings as well as use it standalone.
The hash should be "accessed" with two or more "keys". The last key is interpreted as a sprintf format for each data item specified in the preceeding arguments. This allows you to format multiple items at once using the same format for each.
Alternate name
If you prefer, you can specify a different name for the magical formatting hash by supplying it as as argument when useing the module:
use Tie::Formatted qw(z);
This makes %z the magic hash instead.
print "This is hex: $z{255, "x"}n";
Tie::Formatted currently supports only one format in the final argument; this may change if there is demand for it.
Product's homepage
Requirements:
· Perl