Leser: 28
1 2 3 4 5 6 7 8
my $sitenick = 'aikxdc'; my @Configs = qw(config.pl mysql.pl meta.pl upload.pl markup.pl); for my $cfg (@Configs) { $cfg = "config/" . $sitenick . "/" . $cfg . "; "; eval { require $cfg }; if ( $@ ){ die "Can't load $cfg: $@"; } else { print "Hallo!"; } }
1
2
3
4
/Users/..../global/test.pl:6:
Can't load config/aikxdc/config.pl; :
Can't locate config/aikxdc/config.pl;
in @INC (@INC contains: /Users/..../global /Library/Perl/... usw )
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 # vi:ts=4 sw=4 et: use strict; use warnings; use File::Spec::Functions qw( catdir catfile ); my $base = '/tmp'; my @configs = qw( a.pl b.pl ); my $dir = 'ddd'; for my $cfg ( @configs ) { # falsch #$cfg = catdir( $base, $dir, $cfg ) .';'; #$cfg = catdir( $base, $dir, $cfg ); $cfg = catfile( $base, $dir, $cfg ); eval { require $cfg }; if ( $@ ) { die "Can't load $cfg: $@\n"; } else { print "yes!\n"; } }
2009-07-18T16:56:10 LinuxerOh, das habe ich übersehen. Bin heute wohl etwas schusselig.(…) ein Semikolon an den Dateinamen an.
Guest script im UrlaubPer require eingebundene Skripte müssen auführbar sein!Das Problem scheint bei den Dateirechten zu liegen. Von 644 auf 755 geändert.
2009-07-18T17:35:54 GwenDragonPer require eingebundene Skripte müssen auführbar sein!
Ist auf Unix jedenfalls so.
1
2
3
4
5
6
7
8
9
10
11
12
$ ls -l ./foo.pl
-rw-r--r-- 1 tina tina 72 2009-07-18 22:35 ./foo.pl
$ cat ./foo.pl
package foo;
use strict;
use warnings;
print "Compiling foo.pm\n";
1;
$ perl -wle'require "foo.pl";'
Compiling foo.pm
1 2 3 4 5 6 7 8 9 10 11 12 13
use FindBin; use File::Spec; sub init { my $sitenick = 'aikxdc'; my @Configs = qw(config.cfg.pl meta.cfg.pl upload.cfg.pl); for my $cfg (@Configs) { $cfg = File::Spec->catdir( $FindBin::Bin, "config", $sitenick, $cfg ); eval { require "$cfg" ; }; if ( $@ ){ die "Can't load $cfg: $@"; } else { print STDERR "\nDatei geladen:'$cfg' \n"; } }