Thread Bad name after... (52 answers)
Opened by bianca at 2015-02-19 12:08

bianca
 2015-02-20 14:50
#179773 #179773
User since
2009-09-13
6977 Artikel
BenutzerIn

user image
Sähe dann so aus?
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
#!/usr/bin/perl
use strict;
use warnings;

my @dispatchtab = (
    {
        moduldatei      => 'test_extern.pl',
        aufruf_sub      => \&testsub,
        aufruf_neu      => 'testsub',
        unit            => 'test1',
    },
    {
        moduldatei      => 'test_extern2.pl',
        aufruf_sub      => \&testsub,
        aufruf_neu      => 'testsub',
        unit            => 'test2',
    },
    # hier sind natürlich noch ganz viele
);
foreach my $ref (@dispatchtab) {
    # nur der Code innerhalb dieser Schleife darf geändert werden, sonst nichts!
    package $ref->{unit};
    require $ref->{moduldatei};
#    eval $ref->{aufruf_neu}."('a')";
    UNIVERSAL::can($ref->{unit},$ref->{aufruf_neu}); # $ref->{moduldatei} auch wieder ohne Dateiendung
}


Wirft:
Quote
Invalid version format (non-numeric data) at test.pl line 22, near "package "
syntax error at test.pl line 22, near "package $ref"
Global symbol "$ref" requires explicit package name at test.pl line 23.
Global symbol "$ref" requires explicit package name at test.pl line 25.
Global symbol "$ref" requires explicit package name at test.pl line 25.
syntax error at test.pl line 26, near "}"
Execution of test.pl aborted due to compilation errors.
10 print "Hallo"
20 goto 10

View full thread Bad name after...