in reply to Dynamically requiring a module

You have two options:
  1. Do not use the bareword. Change CONFIG to CONFIG() or &CONFIG wherever called.
  2. Define the sub CONFIG so that the parser knows it, then redefine it with constant. You might want to turn off warnings:
    sub CONFIG () {} { no warnings 'redefine'; if ($ver > 2) { require Config; Config->import; } else { require Settings; Settings->import; } }
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: Dynamically requiring a module
by balachandran (Novice) on Jan 28, 2014 at 07:58 UTC
    This works like a charm! Thanks. The other approach of renaming it to $module->CONFIG would mean a bit more change in a lot of places(though it is just find-replace)