Bonjour,

j'ai un code tout simple qui affiche le résultat d'une capture dans une regex :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
    print "tmp_res = ,$tmp_res,\n" ;
    print "tmp_ref = ,$tmp_ref,\n" ;
pour mes premières regex j'obtient ça (normal) :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
tmp_res = ,off,
tmp_ref = ,on,
et pour la dernière j'obtient ça (regardez la position des virgules) :
[CODE][,mp_res = , Zero entries found toto.
,mp_ref = , Zero entries found.
/CODE]

Si quelqu'un peut m'expliquer...

voici le code complet :

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
sub verifResCom_rtrv_ctrl_feat
{
    (@_ == 1)
        or die ("\nLa methode verifResCom_rtrv_feat prend 1 argument."
                ."\nElle a etait appelee avec ".@_." argument(s).") ;
    my ($cmd) = @_ ;
 
    local $erreur_vu = 0 ;
    local $message = "" ;
    my $tmp_regex = "" ;
    # on charge les texts correspondant à la commande 
    my $txt_res = $hash_res_commandes{$cmd} ;
    my $txt_ref = $hash_res_commandes_ref{$cmd} ;
 
    $tmp_regex = '(IPGWx\s+Signaling\s+TPS\s+\d+)\s+((?:on)|(?:off))' ;
    &compar_rtrv_ctrl_feat ($txt_res, $txt_ref, $tmp_regex) ;
 
    $tmp_regex = '(G-Port\s+Circ\s+Route\s+Prevent\s+\d+)\s+((?:on)|(?:off))' ;
    &compar_rtrv_ctrl_feat ($txt_res, $txt_ref, $tmp_regex) ;
 
    $tmp_regex = '(EAGLE\s+Product\s+\d+)\s+((?:on)|(?:off))' ;
    &compar_rtrv_ctrl_feat ($txt_res, $txt_ref, $tmp_regex) ;
 
    $tmp_regex = '(HC-MIM\s+SLK\s+Capacity\s+\d+)\s+((?:on)|(?:off))' ;
    &compar_rtrv_ctrl_feat ($txt_res, $txt_ref, $tmp_regex) ;
 
    $tmp_regex = '^([\w\s]+temporarily\s+enabled:\s*$\n+\s*'.
                 '^.+$\n+)'.
                 '(^.+$)' ;
    &compar_rtrv_ctrl_feat ($txt_res, $txt_ref, $tmp_regex) ;
 
 
    if ($erreur_vu)
    {
        &ecrirRapport_cmd_nok ($cmd, $message) ;
    }
    else
    {
        &ecrirRapport_cmd_ok ($cmd) ;
    }
}
 
# execute la regex sur les deux textes passés parametre
# la regex doit comporter 2 parenthèses capturante
# une pour l'intitulé l'autre pour la valeur
sub compar_rtrv_ctrl_feat
{
    (@_ == 3)
        or die ("\nLa methode compar_rtrv_ctrl_feat prend 3 argument."
                ."\nElle a etait appelee avec ".@_." argument(s).") ;
    my ($txt_res, $txt_ref, $regex) = @_ ;
 
    $txt_res =~ m/$regex/m ;
    my $message_res = $1 ;
    my $tmp_res = $2 ;
    $txt_ref =~ m/$regex/m ;
    my $message_ref = $1 ;
    my $tmp_ref = $2 ;
 
#    print $message_res." #".$tmp_res."#\n |\n".$message_ref." #".$tmp_ref."#\n" ;
 
    print "tmp_res = ,$tmp_res,\n" ;
    print "tmp_ref = ,$tmp_ref,\n" ;
    unless ($tmp_res eq $tmp_ref)
    {
        $erreur_vu++ ;
        $message = enrichirMessage ($message, $message_res." ".$tmp_res, $message_ref." ".$tmp_ref) ;
    }
}
Merci à tous, Florent.