How about a two level hash representing conversions? A little
redundancy, but convenient access.
my %convert = (
to_currency => { US => 'USD',
USA => 'USD',
MR => 'MRD',
MARS => 'MRD',
},
to_country => { US => 'USA',
USD => 'USA',
MR => 'MARS',
MRD => 'MARS',
},
to_code => { USA => 'US',
USD => 'US',
MARS => 'MR',
MRD => 'MR',
},
);
my $code = 'US';
print "$code currency is: $convert{to_currency}{$code}\n";
print "$code country is: $convert{to_country}{$code}\n";
my $currency = 'USD';
print "Code for $currency is: $convert{to_code}{$currency}\n";
my $country = 'MARS';
print "$country currency is: $convert{to_currency}{$country}\n";
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.