Well the Euro hit the EU today and although I'm in the UK so avoid all the hassles of changing over the contents of my wallet - I thought it would be useful, maybe, to expand on the
Euro article.
The exchange rates from the old currencies to the Euro are now immutable so we can code the rates into our scripts directly - if a rate does change its likely that it would hit the news first.
So what does this mean, well if your company used to deal with Deutch Marks then, from what I have been reading, you have to convert to the Deutch Marks to Euros and then deal with that.
You can read more about it here. The original article does not include the Greek Drachma.
Heres a simple program to do the conversion - by no means is this proggie as complicated as the golfs from the original
Euro article but if someone needs to make a module or something then this should form a simple basis :)
use strict;
use constant RATES => {
'Austrian schilling' => 13.76,
'Belgian franc' => 40.3399,
'Dutch guilder' => 2.20371,
'Finnish markka' => 5.94573,
'French franc' => 6.55957,
'German mark' => 1.95583,
'Greek drachma' => 340.75,
'Irish punt' => 0.787564,
'Italian lira' => 1936.27,
'Portuguese escudo' => 200.482,
'Spanish peseta' => 166.386
};
sub toEuro
{
my ($currency,$amount) = @_;
if(exists(RATES->{$currency}))
{
return RATES->{$currency} * $amount;
}
return;
}
sub toCurrency
{
my ($currency,$amount) = @_;
if(exists(RATES->{$currency}))
{
return $amount / RATES->{$currency} ;
}
return;
}
# Test output :)
print toEuro('French franc',10);
print "\n";
print "\n" . toCurrency('French franc',toEuro('French Franc',10));
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.