Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks,

Can I do something like dynamically loading a .pl file content by some condition?

if($something){ require 'x.pl'; }else{ require 'y.pl'; }

Thank you

  • Comment on dynamicallyloading a .pl file content / load a .pl file by condition?
  • Download Code

Replies are listed 'Best First'.
Re: dynamicallyloading a .pl file content / load a .pl file by condition?
by Anonymous Monk on Mar 29, 2008 at 08:15 UTC
      If I want to avoid using modulus, any idea?
        if (whatever) { eval "use Foo;" } else { eval "use Bar;" }
        If I want to avoid using modulus

        do — but sooner or later you'll realise that using modules is the way to go.