Bonjour à tous,

Je suis entrain de refaire une application perl en java mais j'ai pas de compétemce en perl, j'ai le code suivant est ce que quequ'un pourrait me l'expliquer ou me fournir l'équivalent en java :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
$requete1="
 SELECT subnet.network,
            subnet.net_mask
 FROM    subnet
 ORDER BY subnet.network desc";
$sth=$dbh->prepare($requete1);
$sth->execute();
my $nb=0;
my @list;
my $currad="";
my $curcol=1;
 
my @color=("green","lred","lorange","lred","lorange");
 
while ($pointer=$sth->fetchrow_hashref)
{
  $long=$pointer->{'net_mask'};
  $long=~/(\d+\.\d+\.\d+)\.(\d+)/;
  $long=(256-$2)/4;
 
  $radical=$pointer->{'network'};;
  $radical=~/(\d+\.\d+\.\d+)\.(\d+)/;
  $radical=$1;
  $start=$2/4;
 
  if(!$data{$radical})
   {
    for($i=0;$i<64;$i++)
     {
      $data{$radical}[$i]=0;
     }
    push(@list,$radical);
   }
  if($radical eq $currad)
   {
    $curcol++;
   }
  else
   {
    $curcol=1;
    $currad=$radical;
   }
  for($i=$start;$i<$start+$long;$i++)
   {
    $data{$radical}[$i]=$curcol;
   }
 
}
$sth->finish();
db_disconnect($dbh);
 
print<<EOF;
<table class='table1'>
 <col width=10>
 <col width=120>
 <col width=15 span 64>
 <tr height=50>
  <td></td>
  <td class='c_grey_m'>IP radical name</td>
EOF
for($i=0;$i<256;$i+=4)
 {
  $i=~/(\d)(\d?)(\d?)/;
  if($3 ne '')
   {
    print "   <td class='c_grey_m'>$1<br>$2<br>$3</td>\n";
   }
  elsif($2 ne '')
   {
    print "   <td class='c_grey_m'>$1<br>$2</td>\n";
   }
  else
   {
    print "   <td class='c_grey_m'>$1</td>\n";
   }
 }
 
while(@list)
  {
   $radical=pop(@list);
print<<EOF;
 <tr>
  <td></td>
  <td class='c_white_m'>$radical.0 / 24</td>
EOF
   $i=0;
   $cptcolor=1;
 
   while($i<64)
    {
     $cpt=0;
     $curcol=$data{$radical}[$i];
     while($data{$radical}[$i+$cpt]==$curcol && ($i+$cpt)<64)
      {
       $cpt++;
      }
     if($curcol==0)
      {
       print "  <td class='c_".$color[0]."' colspan=$cpt>&nbsp;</td>\n";
      }
     else
      {
       print "  <td class='c_".$color[$cptcolor]."' colspan=$cpt>&nbsp;</td>\n";
       $cptcolor++;
       if($cptcolor>4)
        {
         $cptcolor=1;
        }
      }
     $i+=$cpt;
    }
Merci d'avance.