Thread hex to decimal conversion (12 answers)
Opened by thegreatonech at 2010-06-10 15:05

murphy
 2010-06-10 16:01
#138190 #138190
User since
2004-07-19
1776 Artikel
HausmeisterIn
[Homepage]
user image
Guest thegreatonech
[...]
@pq: (The first with the second, the third with the forth...) with this I mean the keys of the hash which are from 0 to 511. so i have to put key "0" with key "1" , key "2" with key "3" ...
[...]

Why on earth do you store your data in a hash instead of an array if your keys are consecutive integers?

Anyhow, you can do something like this:
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
use 5.012;

my %hash = ( 0 => 'aa', 1 => 'bb', ... );

my $count = 512;
my $_;

for (0 .. ($count / 2)) {
  my $i = 2 * $_;

  say hex($hash{$i} . $hash{$i + 1});
}

(code untested)
When C++ is your hammer, every problem looks like your thumb.

View full thread hex to decimal conversion