Next Tricks of the Wizards 66

Magical Exporter Variable

     package Format_Money;
     sub FETCH {
       my ($dummy, $amount) = @_;
       my ($dollars, $cents) = split /\./, sprintf("%.2f", $amount);
       1 while $dollars =~ s/^([-+]?\d+)(\d{3})/$1,$2/;     # FAQ
       "\$$dollars.$cents";
     }
     use Format_Money;
     $salary = 43_000;
     print "After your raise, you will make $Money{$salary*1.06}.\n";
        After your raise, you will make $45,580.00


Next Copyright © 2003 M. J. Dominus