August 1999 Return to the Perl Hardware Store Slide #24

Interpolation.pm

        use Interpolation '$' => \&currency,
                          'q' => \&quote_for_CSV,
                          'Cap' => sub { ucfirst lc  $_[0] };
        $s = "$${$PROFITS} in the state of $Cap{$state}";
        $t .= qq{The data are: "$q{$data}".};
        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