Thread Import von Modulen zusammenfassen
(3 answers)
Opened by Manuel at 2010-10-21 16:53
So sollte es gehen:
Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 package Foo; use strict; use warnings; my @modules = qw( Data::Dumper ); sub import { my $package = caller(); foreach my $mod (@modules) { my $code = "package $package; use $mod;"; eval $code; die $@ if $@; } } 1; Code (perl): (dl
)
1 2 3 4 5 6 7 #!/usr/bin/perl use strict; use warnings; use lib '.'; use Foo; print Dumper({ fruit => "banana" }); So macht es zum Beispiel POE. 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. |