Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 676929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:58:58+00:00 2026-05-14T00:58:58+00:00

If my Perl code has a production code location and "beta" code location (e.g.

  • 0

If my Perl code has a production code location and "beta" code location
(e.g. production Perl code us in /usr/code/scripts, BETA Perl code is in /usr/code/beta/scripts; production Perl libraries are in /usr/code/lib/perl and BETA versions of those libraries are in /usr/code/beta/lib/perl, is there an easy way for me to achieve such a setup?

The exact requirements are:

  • The code must be THE SAME in production and BETA location.

    To clarify, to promote any code (library or script) from BETA to production, the ONLY thing which needs to happen is literally issuing cp command from BETA to prod location – both the file name AND file contents must remain identical.

  • BETA versions of scripts must call other BETA scripts and BETA libraries (if exist) or production libraries (if BETA libraries do not exist)

  • The code paths must be the same between BETA and production with the exception of base directory (/usr/code/ vs /usr/code/beta/)

  • The scripts must be all under the same base directory but they may be in its sub-directories at arbitrary depth level (this precludes the classic use lib "$FindBin::Bin/../lib" solution from section 31.13. use lib of "Programming Perl")

I will present how we solved the problem as an answer to this question, but I’d like to know if there’s a better way.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:58:59+00:00Added an answer on May 14, 2026 at 12:58 am

    Our own solution was as follows:

    • Have a library (let’s call it BetaOrProd.pm)

      • The library MUST be included via “use BetaOrProd;” in every script
      • The library MUST be the very first use statement in every script after “use strict;” pragma (and “use warnings” if we use that). Including before any BEGIN blocks.
      • The library has a BEGIN block which contains most of the logic
      • That BEGIN block in the library checks the program’s directory path (based off of $0 with absolute path applied)
      • If the directory path starts with /usr/code/beta, the program is deemed to run in BETA location, else in production
      • In either case, /usr/local/lib/perl is un-shifted to the beginning of @INC list
      • If BETA location, /usr/code/beta/lib/perl is un-shifted to the beginning of @INC list after that.
      • If BETA location, a special variable $isBETA (accessible by a accessor method exported from BetaOrProd.pm) is set to “BETA”.
    • Anytime a script/library needs to call another script, the path to the called script is calculated based on said accessor to $isBETA variable exported from BetaOrProd.pm

    • Anytime a Perl library needs to be required or used, no special logic is needed – the @INC modified by BetaOrProd.pm takes care of knowing where the modules are to be imported from. If the module is present in BETA location, then the library from BETA location will be used by BETA script, else the library from prod location.

    The main drawbacks of this approach are:

    1. Requirement that every script must have “use BetaOrProd;” as the very first use statement in every script after “use strict;” pragma.

      Mitigated by the fact that our company requires every deployed piece of code to pass automated validator, which can check for this requirement.

    2. Can’t BETA test BetaOrProd.pm via /usr/code/beta/lib/perl . D’uh.

      Mitigated by very thorough unit and integration test of the library

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 449k
  • Answers 449k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Use the following: Rectangle rect = new Rectangle(0, 0, 100,… May 15, 2026 at 8:18 pm
  • Editorial Team
    Editorial Team added an answer Yes, you can set the FetchSize on a Statement to… May 15, 2026 at 8:18 pm
  • Editorial Team
    Editorial Team added an answer Modified version of Bogdan's regex using negative lookahead. Replace number… May 15, 2026 at 8:18 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.