note
TomDLux
<p>If you want to put label on a loop so you can use 'next', 'last', 'redo', there's no need to label loops you don't go to. Also, I would suggest using a more meaningful name. Instead of calling the labels OUTER0 and OUTER1, how about naming them SOURCE_CURRENCY and TARGET_CURRENCY?</p>
<p>Going through the elements of %rates isn't what you want to do. The whole point of a hash is to look up keys and determine the corresponding value. Just like the point of an array is to look up the i-th element. I would suggest:</p>
<code>
if ( ! defined $rates{$_} {
print "Don't know how to handle unrecognized rate '$_'.\n";
# handle error in some way.
}
print $rate{$_}
</code>
<p>But since the code is becomming longer, i would definitely suggest using a named variable to store user input, such as $source_currency and $target_currency.</p>
<p>Also, using %rates the way you have, generates a list of a key and it's corresponding value, another key with it's value, for some random ordering of keys. If you really wanted to look at the keys one by one, you can use <c>keys %rates</c> to generate just that list. Similarly, you can use <c>values %rates</c> to generate a list of just the values. The keys and values lists will be in the same order, but may not be the same as you would get on a different machine, or even if add or delete an element.</p>
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-144696">
<p>
As Occam said: <em>Entia non sunt multiplicanda praeter necessitatem.</em>
</p>
</div></div>
1002982
1002982