[quote=renee,16.03.2007, 19:22]ein
use in einem Block-eval ist eh sinnlos (wenn es um Fehlerabfangen des
use geht), da das
use zu Compile-Zeit ausgeführt wird...
Entweder
require verwenden oder das
use-Statement als String-eval machen...[/quote]
jo, wenn es allerdings rein um das Prüfen gehen würde, ob das Modul installiert ist...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use strict;
use warnings;
use Data::TreeDumper;
use File::Spec;
my %modules = (
map { $_ => undef }
qw(IO::Socket IO::Socket::SSL Data::Dumper)
);
foreach my $pm (keys %modules) {
foreach my $path (@INC) {
my $file = File::Spec->catfile($path, split(/::/, $pm)). '.pm';
if (-e $file) {
$modules{$pm} = $file;
next;
}
}
}
print DumpTree(\%modules);
|- Data::Dumper = /usr/lib/perl5/5.8.8/i586-linux-thread-multi/Data/Dumper.pm [S1]
|- IO::Socket = /usr/lib/perl5/5.8.8/i586-linux-thread-multi/IO/Socket.pm [S2]
`- IO::Socket::SSL = /usr/lib/perl5/vendor_perl/5.8.8/IO/Socket/SSL.pm [S3]
Abwägig, aber es klappt. :)\n\n
<!--EDIT|opi|1174070552-->
What is a good module? That's hard to say.
What is good code? That's also hard to say.
One man's Thing of Beauty is another's man's Evil Hack.