On Mon, 30 Jan 2006, Vitaly Sinitsin wrote: > 10x al lot for a short and useful reply. Regarding 2 (require > "$file.pm";): I must "use" and not "require" for compile project+all > packages before loading and not in run time. So, may be you know howto > make it using "use"?
A "use" statement is almost the same as a "require" followed by a call to the import() function inside a BEGIN block, which is what I showed to you. The one remaining difference between my code and the real "use" statement is that is doesn't throw an error if the package doesn't define an import function (most of the time via Exporter). So a better implementation may be: BEGIN { my $pkg = "Foo::Bar"; my @import = qw(some_sub); (my $file = $pkg) =~ s,::,/,g; require "$file.pm"; $pkg->import(@import_list) if UNIVERSAL::can($pkg, "import"); } The only difference is the addition of the if UNIVERSAL::can($pkg, "import") condition for the import() call. Why do you think this would not work for you? Cheers, -Jan _______________________________________________ ActivePerl mailing list ActivePerl@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs