Thread FindBin in Modulen (11 answers)
Opened by pktm at 2008-10-13 21:54

Linuxer
 2008-10-14 00:08
#115482 #115482
User since
2006-01-27
3875 Artikel
HausmeisterIn

user image
Hi,

Code: (dl )
1
2
3
/mylib/a/b.pm 
/mylib/c/d.pm
/script.pl


innerhalb von script.pl sollte doch ausreichen:
Code: (dl )
1
2
use lib '/mylib';
use c::d;


dann sollte innerhalb von /mylib/c/d.pm das hier ausreichen:
Code: (dl )
use a::b;


Oder seh ich da was falsch?

Nachtrag:
Beispiel:
Code: (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
41
42
~/a.pl:
---8<--
#!/usr/bin/perl
# vi:ts=4 sw=4 et:
use strict;
use warnings;
use lib '/tmp';
use bar::foo;

bar::foo->hello();
__END__
---8<--

/tmp/foo/bar.pm:
---8<--
package foo::bar;

sub world {
return "world!";
}

1;
__END__
---8<--


/tmp/bar/foo.pm:
---8<--
package bar::foo;
use foo::bar;

sub hello {
print "hello ", foo::bar::world(), $/;
}

1;
__END__
---8<--

~$ perl ~/a.pl
hello world!
~$


Edit: Nachtrag angepasst; OO aus bar::foo entfernt.
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 FindBin in Modulen