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 3799580
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T13:45:23+00:00 2026-05-19T13:45:23+00:00

I want to make some tests on my modules. Unfortunately, some functions in these

  • 0

I want to make some tests on my modules.

Unfortunately, some functions in these modules use hardcoded configurations files.

package My::Module;

use strict;
use warnings;
use Readonly;

Readonly my $CONF_FILE => '/my/conf_file.xml';

=head1 FUNCTIONS

=head2 Info($appli)

Returns Application Information

=cut

sub Info
{
  my $appli = shift;

  my $conf = MyXML::Read($CONF_FILE);
  foreach my $a (ARRAY($conf->{application}))
  {
    return ($a) if ($a->{name} eq $appli);
  }

  return (undef);
}
[some others functions that use this config file...]

The solution that came to my mind is to create a new function in each module that will change this default config file when I need it.

Then I will use that function in my tests…

Do you have any other (better ?) ideas ?

  • 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-19T13:45:24+00:00Added an answer on May 19, 2026 at 1:45 pm

    Well, the proper thing for me to tell you would be “don’t use hard coded paths”. It’ll come back and bite you at some point in the future, I promise.

    But… assuming you’re resolved to using them, there are a number of ways to allow an override. You’re right you could add a function that would let you change it, or you could use an environmental variable:

      Readonly my $CONF_FILE => $ENV{'MY_CONF_FILE'} || '/foo/bar';
    

    But the right thing to do is still to allow for other items to be passed in properly if you have a choice.

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

Sidebar

Related Questions

i want to make some tests with the Oracle Business Intelligence Webservices. First i
I want to make some basic accessibility tests in RSpec (obviously, to be further
I'm running some benchmark tests over my code and I want to make sure
Let's say I want make some of my sources publicly available via my blog
I want to make some variables I generate in b available in c: a
I want to make some C++ program and I'm using function popen here to
I want to make some changes to the stock Mms Android application and install
I want to make some GUI mockup program for video player, so my idea
i have been programing in vc++ for sometime and i want to make some
I want the user to be able to make some preferences like colors, prefered

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.