Bonjour !
Je viens à vous, car depuis hier je planche sur un beug dont je ne vois pas l'origine. J'ai utilisé la même syntaxe à deux endroits de mon programme, et elle marche une fois mais pas deux...
En fait, je veux stocker un objet Moose, ici "File", dans une hash, avec pour valeur une ref vers une liste de chemins.
Donc, pour prendre en clef un objet, je tie::RefHash ma hash via un constructeur. Ça marche dans un cas, mais pas dans un autre, pourtant similaire.
Voici l'extrait de ma classe qui concerne ce problème :
Bien sûr, je pourrais contourner le problème, mais voyant que ça a marché dans un cas, je ne comprends pas pourquoi là, non !
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 # L'attribut (une hash) que je veux refhasher dans le constructeur - impossible par défaut je crois ? has 'pathUnknownHashRef' => ( is => 'ro', isa => 'HashRef[File]', default => sub{ {} }, reader => 'get_pathUnknownHashRef' ); # Mon constructeur sub BUILD { my $self = shift; tie %{$self -> get_pathUnknownHashRef}, 'Tie::RefHash'; } sub addLog { my $self = shift; my $callingFile = shift; my $failedPath = shift; my $logHashRef = $self -> get_pathUnknownHashRef; my $unknownListRef = $logHashRef -> {$callingFile}; push (@$unknownListRef, $failedPath); $logHashRef -> {$callingFile} = $unknownListRef; print Dumper $logHashRef; # Ici mes clefs sont de type : File=HASH(0x9dfa8e8) # Elles sont donc unblessed, donc inutilisables pour moi }
Cordialement,
Mithryl
Partager