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

I developed a small web-application for use on my home network. Now I have the first stable version, and I want to put the stable files in separate places and continue developing while my family can start using the app.

What I basically need is a mechanism to make a script state 'I want version 0.5 of module Some::Module' and get exactly this version, no higher.

After some super searching and reading the docs for require and use, I came up with the following solutions:

But it seems to me that there must be better solutions since I can't be the first one to deal with that.

Any ideas?

Thanks in advance,
Yosef.

  • Comment on Production / Development on the same server.

Replies are listed 'Best First'.
Re: Production / Development on the same server.
by hardburn (Abbot) on Sep 04, 2003 at 20:27 UTC

    Acme::No, perhaps?

    Update: Also see this perl.com article.

    ----
    I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
    -- Schemer

    Note: All code is untested, unless otherwise stated

Re: Production / Development on the same server.
by BUU (Prior) on Sep 04, 2003 at 20:32 UTC
    Erm, what about just making one folder called 'stable' and another folder called 'development' and say 'only use the files in stable'?
Re: Production / Development on the same server.
by Zaxo (Archbishop) on Sep 05, 2003 at 00:58 UTC

    From 'perldoc -f use',

    use Module VERSION LIST
    ...
    If the VERSION argument is present between Module and LIST, then the "use" will call the VERSION method in class Module with the given version as an argument. The default VERSION method, inherited from the UNIVERSAL class, croaks if the given version is larger than the value of the variable $Module::VERSION.

    That means you can supply a sub VERSION() which has any behavior you like. Your stated desire would go like (untested),

    package Some::Module; use vars qw/$VERSION/; $VERSION = 0.5; sub VERSION { croak unless $_[0] == $VERSION }

    After Compline,
    Zaxo

Re: Production / Development on the same server.
by LameNerd (Hermit) on Sep 04, 2003 at 20:34 UTC
    Maybe you could play around with the PERL5LIB environment variable.
      No, perlrun says it's not used with taint checking. Thanks though, I think I'll use Acme::No if it works (I just downloaded it for testing).
        use lib '/your/directory/lib'; and put the version of the module you want under that directory.

        You'd have to edit this one line to use the proper module version (bummer), but maybe that's acceptable.

Re: Production / Development on the same server.
by dragonchild (Archbishop) on Sep 05, 2003 at 03:46 UTC
    The better solution, especially from a sanity perspective, is to have (at least) two directory trees. A dev, a prod, and possibly a QA. By choosing which directory you're in your URL and making sure that all your modules are in a different place for each environment, you will save yourself a ton of headaches. Plus, it makes promoting code a lot easier. This is especially true if you use the QA option. You mnake sure everything works in QA like you want, then mv prod to prod_save and copy QA to prod. No crazy variable changes ... no versions to mess up ... just ease of development and maintenance.

    Out of curiousity ... what does it do? I've been thinking about writing a simplified Quicken so I can gedt rid of the last Windows machine in the house. It might be an interesting idea to come with a place to advertise useful home apps written in Perl ...

    ------
    We are the carpenters and bricklayers of the Information Age.

    The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

    Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

      This is what I do. what I want is to make scripts in /devel use modules in the devel modules dir, and scripts in /use_me_baby use modules in the production dir, without having to state the directory name, just the module version. I want the appropriate module to be automatically selected by perl, but require and use always select the first they see. I thought Acme::No would do the trick, but it just croaks when version is wrong.

      Any way to do this?

        If you have your directory trees be identical and the modules in some relative path from the scripts, you can have the same use lib statement and because it's running somewhere different, it'll go to a different relative path to find the modules.

        ------
        We are the carpenters and bricklayers of the Information Age.

        The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

        Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.