Thread require findet Datei nicht (18 answers)
Opened by script im Urlaub at 2009-07-18 17:38

Linuxer
 2009-07-18 18:56
#123359 #123359
User since
2006-01-27
3882 Artikel
HausmeisterIn

user image
Hi,

ich habe es mir nochmal angesehen.

Du fügst ein Semikolon an den Dateinamen an.
Wenn Deine Dateinamen keines enthalten, solltest Du es auch nicht anfügen.


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
# 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";
    }
}


edit: fixed typo + grammar
edit2: s/catdir/catfile/
Last edited: 2009-07-20 13:36:26 +0200 (CEST)
meine Beiträge: I.d.R. alle Angaben ohne Gewähr und auf Linux abgestimmt!
Die Sprache heisst Perl, nicht PERL. - Bitte Crossposts als solche kenntlich machen!

View full thread require findet Datei nicht