Thread Subroutine calls über mehrere packages / module (7 answers)
Opened by Haspasus at 2009-11-17 22:15

Gast Haspasus
 2009-11-17 23:46
#128264 #128264
Ich habe nun in allen Dateien das "-w" aus dem Shebang entfernt und überall
Code (perl): (dl )
1
2
use strict;
use warnings;

hinzugefügt.

Desweiteren habe ich nun versucht, das Modul1 mit Instanzen (?) umzusetzen.

Nun klappts aber nicht mehr. Ich bekomme einen Kompilierfehler:
Quote
Global symbol "%self" requires explicit package name at Test/Case/Modul1.pm line 37.
syntax error at Test/Case/Modul1.pm line 37, near "$self{FEHLERFUNC"
Global symbol "$self" requires explicit package name at Test/Case/Modul1.pm line 37.
syntax error at Test/Case/Modul1.pm line 38, near "}"
Compilation failed in require at ./main.pl line 6.
BEGIN failed--compilation aborted at ./main.pl line 6.



Hier die geänderte Modul1.pm:
Code (perl): (dl )
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
package Test::Case::Modul1;

use strict;
use warnings;

sub new {
    my $self = shift;
    my $ref  = {};

    bless($ref, $self);

    $ref->{FEHLERHANDLER}=undef;
    $ref->{FEHLERFUNC}=undef;
    $ref->{FEHLERMSG}="standardfehler";
    $ref;
}

sub setzeFehlerbehandlung {
    my $self               = shift;
    $self->{FEHLERHANDLER} = shift;
    $self->{FEHLERFUNC}    = shift;
}

sub getError {
    my $self = shift;

    return $self->{FEHLERMSG};
}

sub setzeNachricht {
    my $self           = shift;
    $self->{FEHLERMSG} = shift;
}

sub printMessage {
    my $self = shift;
    $self->{FEHLERHANDLER}->$self{FEHLERFUNC}($self->{FEHLERMSG});
}

1;

View full thread Subroutine calls über mehrere packages / module