Gossamer Forum
Home : General : Perl Programming :

declare package from variable

Quote Reply
declare package from variable
Is it possible to declare a package name in a ".pm" file from a variable?

Ex. - file Jon.pm

Code:
my $p = "buddy::Jon";
package $p;
... rest of module...

Thanks,

- Jonathan
Quote Reply
Re: [jdgamble] declare package from variable In reply to
Hi,

Can't say I've ever tried it, but I would imagine you could. Have you tried it? =)

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] declare package from variable In reply to
Andy,

I'm experiementing with the notion of installing a plugin that can work on GForum, GLinks, and GCommunity...

Example, the Tables plugin.

All the includes I can just use an if statement, but it seems difficult to declare the package name...

So I would need something along the following:

Code:
if ($ENV{SCRIPT_FILENAME} ~= m/community.cgi/) {
package Plugins::Community::Jon;
}
else {
package Plugins::Jon;
}

Obviously that won't work, but I'm stipulating that it is possible somehow.

Any ideas?

Thanks,

- Jonathan
Quote Reply
Re: [jdgamble] declare package from variable In reply to
Hi,

Mmm - in that case, not sure it would work (cos I believe packages need to be declared prior). However, it can't hurt to try Smile

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates