So ganz ist mir nicht klar, was genau Dein Problem ist...
Ich gehe jetzt mal von folgendem Programm aus:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use v5.10;
use strict;
use warnings;
use constant {
BEFORE => 'BEFORE',
};
my $self = {
HOOK => {
hello => {
BEFORE => 'welt',
123 => 'eine zahl',
}
}
};
my $method = 'hello';
say $self->{HOOK}->{$method}->{BEFORE};
Wenn man das ausführt, kommt
welt raus. Soweit so gut. Wenn Du
use constant {
BEFORE => 'BEFORE',
};
in
use constant {
BEFORE => '123',
};
ändert, erwartest Du eine Änderung des Verhaltens?
Das wird nicht passieren, weil - wie rosti schon sagte - das
BEFORE in
->{BEFORE} als String interpretiert wird. Willst Du da den Wert der Konstanten benutzen, musst Du
->{BEFORE()} nutzen ("use constant" erstellt für die Konstanten Subroutinen plus etwas "Magie") oder
->{"".BEFORE}.