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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:31:17+00:00 2026-05-17T01:31:17+00:00

I have 5 Perl files that are verification scripts for 5 different states of

  • 0
  • I have 5 Perl files that are verification scripts for 5 different states of my environment.

    Each of them has at least a couple of subroutines.

  • Till now, the number of states was limited to 5 and these worked fine. But now, I have like 20 more states of the environment and hence 20 more Perl scripts according to the current design.

  • I want to move all the five scripts to just one script which takes the state as an argument and have 5 different subroutines for 5 different states.

    This way, when I need to add a verify for yet another state, I will just have to define a new subroutine instead of a whole new Perl script.

  • The problem is that it will mean using nested subroutines (which are known to run into issues), or unrolling the subroutines themselves.

For example,

original scripts

$ cat verify1.pl
sub a1 {
    ...
}
sub b1 {
    ...
}
a1(); b1(); a1();
$ cat verify2.pl
sub a2 {
    ...
}
sub b2 {
    ...
}
sub c2 {
    ...
}
a2(); b2(); c2(); a2();
$

consolidated script

$ cat verify.pl
sub one {
    ...
}
sub two {
    ...
}
my ($arg) = @ARGV;
if ($arg == 1) {
    one();  # should do what verify1.pl did
}
elsif ($arg == 2) {
    two();  # should do what verify2.pl did
}
$

What should I do to resolve this?

  • 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-17T01:31:17+00:00Added an answer on May 17, 2026 at 1:31 am
    sub one {
        do 'verify1.pl';
    }
    sub two {
        do 'verify2.pl';
    }
    

    In the long run, however, it is better to convert your scripts into modules in order to manage the complexity in a modern and sane fashion.

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

Sidebar

Related Questions

I have a perl file that takes in txt files and compares them to
I have two Perl files: action.pl and the other is test.pl action.pl has a
Have a perl script that needs to process all files of a certain type
I have a Perl program that stores regular expressions in configuration files. They are
I have a perl script that prepares files for input to a binary program
I have a Perl script that uses WWW::Mechanize to read from a file and
I have a perl program that takes input and output file arguments, and I'd
I have a perl script that's reading an INI file like this: [placeholder_title] Hostname
On Computer A (my computer), I have a Perl script that accesses a file
I have a perl one-liner in a Makefile to edit files in place: perl

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.