August 1999 | Return to the Perl Hardware Store | Slide #24 |
The syntax actually looks like this:
use Interpolation '$' => \¤cy, 'q' => \"e_for_CSV, 'Cap' => sub { ucfirst lc $_[0] };
$s = "$${$PROFITS} in the state of $Cap{$state}"; $t .= qq{The data are: "$q{$data}".};
Prevents cluttering of code with lost of calls to formatting functions
Attention focused on output rather than on formatting code
Define formatters with mnemonic names like $currency or $Cap.
Clever hack:
use Interpolation 's' => 'sprintf1';
print "Profits were up by $s{'%2.2f',$amt} percent.\n";
Inserts sprintf call into a quoted string.
Next | Copyright © 1999 M-J. Dominus |