in reply to Can't Use an undefined value as a HASH reference when passing HASH key into Excel OLE call.
A quick test proves that hash keys are strings, so your trick of adding zero is safe and you don't need my int nonsense. But there is a different trap waiting for you, as you are sorting the keys. The keys are strings and therefore will be sorted in ASCIIbetical order, not numeric order. This trap is waiting for me in some of my code.
use strict; use warnings; use diagnostics; my %hash = (1 => 'One', 2 => 'Two', 11 => 'Eleven', 100 => 'Hundred'); for my $key (sort keys %hash){ print $key . " " . $hash{$key} . "\n"; }
Regards,
John Davies
|
|---|