conditional modules

J

John

Hi

Can you access modules with a condition, ie

my ($language,$text);
if ($language eq 'English') {use English; $text=new English;}
elsif ($language eq 'German') {use German; $text=new German;}
etc

or is this preferable

use Language qw(english};

I don't want to load all languages when I am going to use only one.

Regards
John
 
S

smallpond

Hi

Can you access modules with a condition, ie

my ($language,$text);
if ($language eq 'English') {use English; $text=new English;}
elsif ($language eq 'German') {use German; $text=new German;}
etc

or is this preferable

use Language qw(english};

I don't want to load all languages when I am going to use only one.



=== foo ===
$pkg = shift;
eval "use $pkg";
MainWindow->new();
MainLoop();

perl foo Tk

This brought up a Tk window so I guess runtime
package binding is fine.

You need to eval the use statement that you want to
do to avoid having all of your packages loaded at
compile time.
 
P

Petr Vileta \fidokomik\

John said:
Hi

Can you access modules with a condition, ie

my ($language,$text);
if ($language eq 'English') {use English; $text=new English;}
elsif ($language eq 'German') {use German; $text=new German;}
etc

my ($language,$text);
if ($language eq 'English') {require English; $text=new English;}
elsif ($language eq 'German') {require German; $text=new German;}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top