in reply to Re: Using variables within use and package statement
in thread Using variables within use and package statement

This solution works for use statments , But for package
name is there an option ?

package newpath::gui::newfile;

can newpath be replaced with any variables in defining
package names?
  • Comment on Re^2: Using variables within use and package statement

Replies are listed 'Best First'.
Re^3: Using variables within use and package statement
by BrowserUk (Patriarch) on Oct 06, 2005 at 07:29 UTC

    Unless I am misunderstanding you, you shouldn't need to do that?

    The 'normal' way of doing things is:

    --- file \this\path\gui\skills_gui.pm -- package skills_gui; ... ---------------------------------------- --- file \this\path\db\skills_db.pm -- package skills_db; ... ---------------------------------------= --- file \that\path\gui\skills_gui.pm -- package skills_gui; ... ---------------------------------------- --- file \that\path\db\skills_db.pm -- package skills_db; ... ---------------------------------------=

    And in the calling script have

    ---- File: \some\other\path\yourscript.pl --- use lib $ENV{LIB_PATH}; use gui::skills_gui; use db::skills_db; ....

    For one run of the script set LIB_PATH=\this\path\ and it will use \this\path\gui\skills_gui.pm and \this\path\db\skills_db.pm
    and for another run you'd set LIB_PATH=\that\path\ and it will use \that\path\gui\skills_gui.pm and \that\path\db\skills_db.pm.

    So the one script unchanged will use either set of modules depending upon the setting of the environment variable.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.
Re^3: Using variables within use and package statement
by chromatic (Archbishop) on Oct 06, 2005 at 07:04 UTC

    No (unless you want to rewrite your symbol tables, but don't do that).

Re^3: Using variables within use and package statement
by blazar (Canon) on Oct 06, 2005 at 08:18 UTC
    This solution works for use statments , But for package name is there an option ?
    None that I know (IIUC). That is: none that is not in the real of brainf***ed solutions. But you don't want to do that: just either use OO syntax directly or export whatever you need to, if you prefer a functional UI.