Bonjour à tous !!
J'ai un gros problème ...
Je vous explique.
a travers un formulaire, je veux récupérer des données qui vont me servir à créér un message à partir d'un message template.
Voici à quoi ressemble mon message template:
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 UNB+UNOA:1+[T_SUPPLIER_IDENTIFICATION]:14+[T_CUSTOMER_IDENTIFICATION]:14+[T_DATE]:[T_HOUR]+[T_COUNT]++INVOICE+++EANCOM UNH+56+INVOIC:D:93A:UN:EAN007 BGM+325+[T_COUNT] DTM+137:[T_DATE]:102 RFF+ON:[T_ORDER_REFERENCE] RFF+AAK:[T_BOL_REFERENCE] DTM+171:[T_DATE]:102 NAD+BY+[T_CUSTOMER_IDENTIFICATION]::9 NAD+SU+[T_SUPPLIER_IDENTIFICATION]::9 NAD+DP+[T_CUSTOMER_IDENTIFICATION]::9 CUX+2:DEM:10 LIN+1++[T_EAN_CODE]:EN::9 PIA+5+[T_SUPPLIER_CODE]:SA+[T_CUSTOMER_CIDE]:IN QTY+47:[T_QUANTITY]:[T_UNIT_OF_MEASURE] MOA+203:[T_NET_AMOUNT] PRI+AAA:[T_UNIT_PRICE]:[T_UNIT_PRICE_MEASURE] TAX+7+VAT+++:::[T_VAT_RATE]+S MOA+125:[T_NET_AMOUNT] UNS+S MOA+9:[T_TOTAL_AMOUNT] TAX+7+VAT+++:::[T_VAT_RATE]+S MOA+176:[T_VAT_AMOUNT] UNT+22+01 UNZ+1+[T_COUNT]
A travers un formulaire CGI je récupère mes variables passées qui ont pour nom ce qui est entre crochet dans le message template.
Ensuite je place ses variables dans un hash %VAR.
Tout ceci fonctionne bien
Mais lorsque je veux remplacer mes [...] du message template par les données récupérées du formulaire, j'obtiens un résultat très bizarre
Voici le script qui récupère les données du formulaire et créé un message:
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 #!c:\perl\bin\perl.exe use TX2::Web::Session; use TX2::Tools; $cgi = new CGI; $session=&TX2::Web::Session::Verify($cgi->param("CGISESSID")); $id=$session->id(); @params = $cgi->param(); $paf_template = '../paf.template'; open(FIC,$paf_template) or die "Error opening $paf_template $!\n"; $TEMPLATE = join("",<FIC>); close(FIC); print "Content-type:text/html\n\n"; #Génération d'un identifiant unique que l'on place dans le hash %VAR $VAR{'[T_COUNT]'} = &TX2::Tools::Generate(); #Récupération des données du formulaire dans le hash %VAR foreach(@params) { $VAR{'['.$_.']'} = $cgi->param($_); } #On remplace tous les "tags" du template par le contenu du formulaire (contenu dans le hash %VAR) foreach my $keys (keys %VAR) { $TEMPLATE=~s/$keys/$VAR{$keys}/msgi; } print "$TEMPLATE\n<BR>";
Et voici à quoi ressemble $TEMPLATE
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 UPUP50UPUP6UP901000150UPUP6UP9010001+UPUP301576UP00708301576UP00708:UP+[UPUP301576UP00708UPUPUP301576UP00708UPUPUPUPUP301576UP00708UPUPUPUP301576UP00708UPUP301576UP00708UPUP301576UP00708UP]:UP4+[UPUPUPUP301576UP00708UP301576UP00708UPUPUPUPUP301576UP00708UPUPUPUP301576UP00708UPUP301576UP00708UPUP301576UP00708UP]:UP4+[UPUP301576UP00708301576UP00708UPUP]:[UPUP10301576UP00708UPUP]+[UPUPUP301576UP00708UPUPUP]++UPUPUPxUPUP103g301576UP00708UPUPUP+++UP301576UP00708UPUP301576UP00708UP UPUP10+56+UPUPUPxUPUP103g301576UP00708UPUP:301576UP00708:93301576UP00708:UPUP:UP301576UP00708UP007 50UPUP6UP901000150UPUP6UP901000150UPUP6UP901000150UPUP6UP9010001550UPUP6UP901000150UPUP6UP901000150UPUP6UP901000150UPUP6UP901000150UPUP6UP901000150UPUP6UP901000150UPUP6UP9010001UP99UP50UPUP6UP901000150UPUP6UP901000183388550UPUP6UP901000137950UPUP6UP901000101350UPUP6UP901000150UPUP6UP901000150UPUP6UP901000150UPUP6UP901000150UPUP6UP901000150UPUP6UP901000150UPUP6UP901000151UP+3UP5+[UPUPUP301576UP00708UPUPUP] 301576UP00708UPUP+UP37:[UPUP301576UP00708301576UP00708UPUP]:UP0UP UP301576UP00708301576UP00708+301576UP00708UP:[UPUP301576UP00708UP301576UP00708UPUPUPUPUP301576UP00708UPUPUPUPUPUP] UP301576UP00708301576UP00708+301576UP00708301576UP00708K:[UPUP50UPUP6UP901000150UPUP6UP9010001301576UP00708301576UP00708UPUPUP301576UP00708UPUPUPUPUPUP] 301576UP00708UPUP+UP7UP:[UPUP301576UP00708301576UP00708UPUP]:UP0UP UP301576UP00708301576UP00708+50UPUP6UP901000150UPUP6UP90100011+[UPUPUPUP301576UP00708UP301576UP00708UPUPUPUPUP301576UP00708UPUPUPUP301576UP00708UPUP301576UP00708UPUP301576UP00708UP]::9 UP301576UP00708301576UP00708+301576UP00708UP+[UPUP301576UP00708UPUPUP301576UP00708UPUPUPUPUP301576UP00708UPUPUPUP301576UP00708UPUP301576UP00708UPUP301576UP00708UP]::9 UP301576UP00708301576UP00708+301576UP00708UP+[UPUPUPUP301576UP00708UP301576UP00708UPUPUPUPUP301576UP00708UPUPUPUP301576UP00708UPUP301576UP00708UPUP301576UP00708UP]::9 UPUPX+UP:301576UP00708UPUP:UP0 301576UP00708UPUP+UP++[UPUPUP301576UP00708UPUPUP301576UP00708301576UP00708UP]:UPUP::9 UPUP301576UP00708+5+[UPUP301576UP00708UPUPUP301576UP00708UPUPUPUPUP301576UP00708301576UP00708UP]:301576UP00708301576UP00708+[UPUPUPUP301576UP00708UP301576UP00708UPUPUPUPUPUP301576UP00708UP]:UPUP 1UP1+47:[UPUP1UP301576UP00708UPUPUPUP1]:[UPUPUPUPUPUPUP301576UP00708301576UP00708UPUPUP301576UP00708301576UP00708UPUPUP] UP301576UP00708301576UP00708+UP03:[UPUPUPUPUPUP301576UP00708UP301576UP00708UPUPUP] UPUPUP+301576UP00708301576UP00708301576UP00708:[UPUPUPUPUPUPUPUPUPUPUPUP]:[UPUPUPUPUPUPUPUPUPUPUPUPUPUPUP301576UP00708301576UP00708UPUPUP] UP301576UP00708X+7+UPxUPUP103g301576UP00708UP+++:::[UPUPUPxUPUP103g301576UP00708UPUPUP301576UP00708UPUP]+301576UP00708 UP301576UP00708301576UP00708+UPUP5:[UPUPUPUPUPUP301576UP00708UP301576UP00708UPUPUP] UPUP301576UP00708+301576UP00708 UP301576UP00708301576UP00708+9:[UPUPUP301576UP00708UP301576UP00708301576UP00708UP301576UP00708UP301576UP00708UPUPUP] UP301576UP00708X+7+UPxUPUP103g301576UP00708UP+++:::[UPUPUPxUPUP103g301576UP00708UPUPUP301576UP00708UPUP]+301576UP00708 UP301576UP00708301576UP00708+UP76:[UPUPUPxUPUP103g301576UP00708UPUP301576UP00708UP301576UP00708UPUPUP] UPUPUP+UPUP+0UP UPUPZ+UP+[UPUPUP301576UP00708UPUPUP]
je pense bien qu'il y a un problème dans la syntaxe suivante:
mais quel est le problème ???
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 #On remplace tous les "tags" du template par le contenu du formulaire (contenu dans le hash %VAR) foreach my $keys (keys %VAR) { $TEMPLATE=~s/$keys/$VAR{$keys}/msgi; }
merci grandement pour votre aide précieuse !!!
Partager