Next The Perl Hardware Store DC.pm Version 60

Interpolation.pm

        sub FETCH {
          $_[1];
        }
        sub FETCH {
          my $key = sprintf("%.2f", abs($_[1]));
          my $positive = $_[1] > 0;     
          1 while $key =~ s/^([-+]?\d+)(\d{3})/$1,$2/;     # FAQ
          $positive ? " \$$key " : "(\$$key)";
        }
     use Eval '$';
     $EARNINGS = 47387.12;
     $EXPENSES = 55337.48;
     print "This year we earned $${$EARNINGS} and expended $${EXPENSES}.\n"
     print "Net profits were $${$EARNINGS-$EXPENSES}.\n";

prints

     This year we earned  $47,387.12  and expended  $55,337.48.
     Net profits were ($7,950.36).


Next Copyright © 2003 M. J. Dominus