Leser: 19
Guest thegreatonechI've got a hash. every key has a hexadecimal value with two signs like "fe" or "05" or "f4".
QuoteI have to put two of this hexs together to a hex with four signs like "fe05". (The first with the second, the third with the forth...)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
for ($x=0; $x<=511; $x=$x+2){
$z=$x+1;
if (hex($temp{$x}) > hex($temp{$z})){
$string1 = $temp{$z};
$length = length($string1);
if ($length eq 1){
$string1 = "0".$string1;
}
$string2 = $temp{$x};
$length1 =length($string2);
if ($length1 eq 1){
$string2 = "0".$string2;
}
$hexzahl = $string1.$string2;
$deczahl = hex($hexzahl);
$calibtemp{$y}= $deczahl;
$calibtemp1{$y}= $hexzahl;
}
else{
$string1 = $temp{$z};
$length = length($string1);
if ($length eq 1){
$string1 = "0".$string1;
}
$string2 = $temp{$x};
$length1 =length($string2);
if ($length1 eq 1){
$string2 = "0".$string2;
}
$hexzahl = $string2.$string1;
$deczahl = hex($hexzahl);
$calibtemp{$y}= $deczahl;
$calibtemp1{$y}= $hexzahl;
}
open (filename, ">>tempi.dat") or die "Fehler","\n";
print filename "$y"," ","$calibtemp{$y}","\n";
print filename "$y"," ","$calibtemp1{$y}","\n";
close (filename);
$y++;
}
Guest thegreatonech[...]
but the problem is that here i putted always the string with the lower value in front of the string with the higher value but thats not always right.
[...]
Quotemeans the the low order digits are given first, followed by the high order digits.low - high representation
QuoteThe description certainly doesn't mean that you have to sort the values before concatenating them. It's very likely that means the the low order digits are given first, followed by the high order digits.
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" ...
[...]
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}); }