Use Data::Dumper or similar to examine your data whenever you get something weird like this. Your two hashes are very different. First time through (on solution):
$VAR1 = {
'ParisFR' => ' 264.965452179665817',
'Montana' => ' 7596.858969274226183',
'Correze' => ' 639.457965193499604'
};
Second time through (problem):
$VAR1 = {
'ParisFR' => bless( {
'unit' => 'kilometre',
'values' => {
'kilometre' => '264.9654
+52179666'
}
}, 'Class::Measure::Length' ),
'Montana' => bless( {
'unit' => 'kilometre',
'values' => {
'kilometre' => '7596.858
+96927423'
}
}, 'Class::Measure::Length' ),
'Correze' => bless( {
'unit' => 'kilometre',
'values' => {
'kilometre' => '639.4579
+651935'
}
}, 'Class::Measure::Length' )
};
The way forward always starts with a minimal test.