Précédent   Forum du club des développeurs et IT Pro > Autres langages > Perl > Programmation et administration système
Programmation et administration système Vos questions sur les scripts d'administration système, création de compte utilisateur, socket, fork, ping, etc...
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 23/04/2012, 11h24   #1
bdptaki
Membre du Club
 
Inscription : septembre 2006
Messages : 264
Détails du profil
Informations forums :
Inscription : septembre 2006
Messages : 264
Points : 66
Points : 66
Par défaut Pobléme affichage avec le padding

J'ai un probléme d'affichage d'une valeur !

Je veux qu'elle est le format en sortie avec un padding de 11 ( complété par des 0).

voila mon script :
Code :
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
 
$sql = qq{select FCP.FCP_MANUEL_SAISIES.DATE_OP, 
			fcp.FCP_MANUEL_SAISIES.c_etab, 
			fcp.FCP_MANUEL_SAISIES.c_agence, 
			fcp.FCP_MANUEL_SAISIES.n_contrat,
			fcp.FCP_MANUEL_SAISIES.c_isin, 
			fcp.FCP_MANUEL_SAISIES.MONTANT
		from fcp.FCP_MANUEL_SAISIES
		};
 
#######################La requete sql#########
 
 
while(@dat = $st->fetchrow)	{
		$ligne=$dat[0];
		for ($i=0;$i<=@dat;$i++) {
 
 
 
			if ($i == 5) {
 
				printf "Test1 : ".$dat[5]."\n" ;
				$montantPadding = $dat[5] ;
				$montantPadding =~ s/,+/ /;	
				$montantPadding =~ s/\s+//g;
				$montantPadding = printf("%011d\n", $montantPadding) ;	
				printf $montantPadding."\n" ;
				$dat[5] = $montantPadding ;
 
 
				printf "dat[5] = ".$dat[5]."\n" ;
 
			}
			#printf $dat[5]."\n" ;
 
			$ligne=$ligne.";".$dat[$i];
 
		}
 
		$compteurLigne = $compteurLigne + 1 ; 	
		$entete = printf("%.02d;", 24) ;
		$cptLigne = printf("%.06d;", $compteurLigne) ;	
		$codeStructure = printf("%.02d;", 60) ;				
		$ligne=$ligne."\n";
 
		print FCP_MANUEL_SAISIES $ligne;
	}
}
Da boucle du for, dans le test je veuc avoir en sorti pour la commande suivante
Code :
printf $montantPadding."\n" ;
juste le nomtant avec le padding.

Sauf que je récupére un 1 en plus !

Je ne vois pas d'où peux venir l'erreur, est ce qu'une personne aurait une idée la dessus !
bdptaki est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 23/04/2012, 15h59   #2
bdptaki
Membre du Club
 
Inscription : septembre 2006
Messages : 264
Détails du profil
Informations forums :
Inscription : septembre 2006
Messages : 264
Points : 66
Points : 66
C'est bon j'ai trouvé , erreur de formatage

Code :
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
while(@dat = $st->fetchrow)	{
		$ligne="";
		#printf $ligne."\n" ;
		for ($i=0;$i<@dat-1;$i++) {
 
 
			#$ligne=$ligne.";".$dat[$i];
			$ligne=$ligne.";".$dat[$i];
		}
		#$ligne= $ligne."                                                                                                                               ";
		$compteurLigne = $compteurLigne + 1 ; 
		$entete = printf("%.02d;", 24) ;		
		$cptLigne = sprintf("%.06d;", $compteurLigne) ;
		$NB_MOUV = $cptLigne ; 
		$NB_MOUV = printf("%.06d;",$NB_MOUV) ;
		$codeStructure = printf("%.02d;", 60) ;
 
		#$ligne=$ligne."\n";			
 
			$montantPadding = $dat[6] ;
			$montantPadding =~ s/,+/ /;	
			$montantPadding =~ s/\s+//g;
			$montantPadding = sprintf("%.11d", $montantPadding) ;	
			$ligne = $ligne.";".$montantPadding ;
 
		$ligne = $ligne.";".$montantPadding."\n" ;		
 
		print FCP_MANUEL_SAISIES $ligne;
	}
 
 
	$cptLigne = $cptLigne + 1 ;
	$cptLigne = sprintf("%.06d", $cptLigne) ;
	$NB_MOUV = sprintf("%.07d", $cptLigne -2 ) ;
Pour ceux qui veulent @++
bdptaki est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Cette discussion est résolue.
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 12h08.


 
 
 
 
Partenaires

Hébergement Web