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"?
> -------Original Message-------
> From: Jan Dubois <[EMAIL PROTECTED]>
> Subject: RE: Pass package name as variable
> Sent: 30 Jan '06 09:51
>
> On Sun, 29 Jan 2006, Vitaly Sinitsin wrote:
> > is it possible to pass the package_name as variable and how in the
> following example:
> > ${package_name::GLOBAL} = $abc;
>
> Sure:
>
> ${$package_name."::GLOBAL"} = $abc;
>
> or
>
> ${"${package_name}::GLOBAL"} = $abc;
>
> > And, in the same manner, is it possible and how to use variable instead of
> package name in the:
> > use package;
>
> You'll have to use require() inside a begin block. Instead of
>
> use Foo::Bar qw(some_sub);
>
> you would have to write something like this:
>
> BEGIN {
> my $pkg = "Foo::Bar";
> my @import = qw(some_sub);
>
> (my $file = $pkg) =~ s,::,/,g;
> require "$file.pm";
> $pkg->import(@import_list);
> }
>
> Depending on your use case you may not need to put things into a BEGIN
> block, especially if
> you don't need to import symbols from the other package.
>
> Cheers,
> -Jan
>
>
>
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs