Bonjour,
Je debute dans le perl, et je rencontre un souci sur l'objet
pour resumer j'ai un objet "FichierPilote (FP)" qui contient une liste d'objet "Page"
je souhaite crée une methode GetPage(numero) pour l'objet "FP".
cependant quand je renvoi la ref pour perl l'objet ou la var qui recoit l'objet n'est pas initialisé.
En images ;-)
le main
La methode GetPage du FichierPilote
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 use ClsFichierPilote; use diagnostics; $pilote = ClsFichierPilote->new(); $pilote->LoadFile("/netapp8/racine1/ligne_cgi/Config/test/perl/scan.lad.edit"); $page = $pilote->GetPage(2); print ref($page); print ("retour\n"); print $page->GetAttrValue("FICHE", "xgh");
LE message d'erreur
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 sub GetPage { $this = shift; $dp = shift; $nb = scalar(@{ $this->{LIST_PAGES} }); print "GETPAGE $dp CALLED\n"; print "nb page = $nb\n"; foreach $page (@{ $this->{LIST_PAGES} }) { print "PAGE $page->{DP} FOUND\n"; return $page if($page->{DP} == $dp); } return undef; }
Si vous pouviez m'aider....merci ;-)
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 $ perl Main.pl avant GETPAGE 2 CALLED nb page = 20 PAGE 1 FOUND PAGE 2 FOUND ClsPage retour Use of uninitialized value in scalar dereference at ClsPage.pm line 86 (#1) (W uninitialized) An undefined value was used as if it were already defined. It was interpreted as a "" or a 0, but maybe it was a mistake. To suppress this warning assign a defined value to your variables. To help you figure out what was undefined, perl tells you what operation you used the undefined value in. Note, however, that perl optimizes your program and the operation displayed in the warning may not necessarily appear literally in your program. For example, "that $foo" is usually optimized into "that " . $foo, and the warning will refer to the concatenation (.) operator, even though there is no . in your program. Use of uninitialized value in print at Main.pl line 33 (#1)
Partager