package Calc::Euro; use strict; use Carp; my %rates = qw( LUF 40.3399 ATS 13.7603 BEF 40.3399 NLG 2.20371 FIM 5.94573 FRF 6.55957 DEM 1.95583 GRD 340.75 IEP 0.787564 ITL 1936.27 PTE 200.482 ESP 166.386 ); sub new { my ($proto, $currency) = @_; my $rate = defined $currency && ( $rates{uc $currency} || 0 + $currency ) || ( ref $proto eq __PACKAGE__ ? $$proto : croak("Invalid currency") ); return bless \$rate, ref($proto) || $proto; } sub to_euro { my ($self, $amount) = @_; return $amount / $$self; } sub to_national { my ($self, $amount) = @_; return $amount * $$self; } sub from_euro { goto &to_national } sub from_national { goto &to_euro } sub clone { goto &new }