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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:49:58+00:00 2026-06-16T03:49:58+00:00

I am new to Perl programming and would like to get some ideas on

  • 0

I am new to Perl programming and would like to get some ideas on what is the best way to structure a piece of code in the form of Perl module(s). It should provide a framework such that the ‘data’ can grow/shrink without impacting the code.

Essentially, the program needs to perform 3 different things (‘data’ portion):

  1. Gather text from multiple files(entire text) depending upon which RPM (RPM name = ‘A’, ‘B’, ‘C’ respectively, for argument’s sake) is installed on the host. The list of files will grow and should be stored in a simple externalized file which should be easily editable.
  2. Run OS commands on the operating system (Linux) and capture the output of the commands into a text file, depending upon which RPM (RPM name = ‘A’, ‘B’, ‘C’, for argument’s sake) is installed on the host.
  3. Run Database commands on a specific database (lets call it ‘DBA’, ‘DBB’, ‘DBC’, 3 databases corresponding to 3 hosts) and capture the output to a text file, depending upon which RPM (RPM name = ‘A’, ‘B’, ‘C’ respectively, for argument’s sake) is installed on the host.

I need to program the logic in such a way that:

  1. There has to be a “RPM to file/command/DB-command” mapping which is easily editable separately from the main Perl program
  2. The number of files, their names/location + OS + DB commands is expected to change and therefore should be easily editable separately from the main Perl program
  3. The RPM name and the mapping to the above data can change and therefore should be easily editable separately from the main Perl program

Ideas that I have researched so far:

  1. Hash of Hashes (in a Perl module)
  2. Array of Arrays (in a Perl module)
  3. external XML
  4. external Key-value pair file

Any guidance on whats the easiest and simplest way to go about doing this? Illustrative code would be greatly beneficial.

  • 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-06-16T03:49:59+00:00Added an answer on June 16, 2026 at 3:49 am

    How you store your configuration depends on how complex it is, and how accessible it has to be to someone who didn’t program the system.

    The benefit of storing configuration as Perl code is, that parsing is quite inexpensive. However, there may be security concerns, as the config file wouldn’t be loaded, but executed. Also, it is a horrible design.

    XML is quite flexible, but is (a) horrible to edit manually, and is (b) more expensive to process than other solutions[citation needed].

    If your configuration data can be very easily represented as key-value pairs, go for that. Else, take a look at JSON or YAML, which will give you all the power you will need (most of the time).


    I would write the system in such a way, that a main object is loaded at the start of the program. The constructor takes the RPM type as argument, and processes the appropriate configuration files.

    You would then create an interface to this object so that processing text files, running system commands and running DB queries would use the correct config values.

    Just make sure to make your code nice and generic, so that the main logic of the programm doesn’t need to know what RPM it is using, except at initialization.

    A Perl class usually is a module at the same time. Create helper modules as needed, when it is sensible.


    • Perl Object Orientated Programming Tutorial
    • YAML documentation
    • JSON documentation

    Example constructor:

    package MyObject;
    use strict; use warnings; use Carp;
    use YAML qw(LoadFile);
    my $config_file_dir = "/foo/bar/";
    sub new {
       my ($class, $type) = @_;
       do_rpm_type_sanity_check($type) or confess qq(Invalid type given: $!);
       my $self = LoadFile($config_file_dir . $type . ".yaml");
       do_config_sanity_check($self) or confess qq(Really weird configuration: $!);
       bless $self, $class;
    }
    

    Example usage

    #!/usr/bin/perl
    use strict; use warnings;
    use MyObject;
    
    my $type = magically_get_type();
    
    my $obj = MyObject->new($type);
    ...; # do something useful with the object.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to perl programming and would like to know about parsing text
I'm reading Programming Perl , and I found this code snippet: sub new {
I am new in expect perl programming and have to write some scripts to
I'm very new to Perl programming. I've just finished reading the Llama book. Up
As a PHP programmer new to Perl working through 'Programming Perl', I have come
Kinda new to Perl. I am using Perl web API to get the data.
I am fairly new to Perl programming, but I have a fair amount of
I am new to perl programming. I have a scenario where a username is
I'm relatively new to Perl, writing some XML parsing scripts. I have done two
I have some coding and already pushed this into a variable. I would like

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.