Hi Monks,
My current script looks something like this:
if ($ARGV[0] eq "-H"){
print "Help goes here\n";
} elsif ( $ARGV[0] eq "-L") {
print "List of things here\n";
} elsif ( $ARGV[0] eq "-Action") {
my $parameter1 = $ARGV[1];
my $parameter2 = $ARGV[2];
print "Rest of program here\n";}
but I want to add things like example 4, and maybe 5 :
Example 1 bash$ ./scriptname.pl action_1
# this already works
or
Example 2 bash$ ./scriptname.pl action_2
# this already works
or
Example 3 bash$ ./scriptname.pl action_3 parameter1 parameter2
# this already works
or
Example 4 bash$ ./scriptname.pl action_4 parameter1 parameter2
or
Example 5 bash$ ./scriptname.pl action_N parameter1 parameter2
.
.
.
The script started out with a single purpose and it flows well enough. I set
it up with as many subroutines as possible and I just run down the script
calling subroutines where I can until I get to the end. Now that I want to add more
functionality where additional actions will be determined on the command line I'm not sure how to do it. I only want to do one action at a time but am not sure how to organize the script.
I have 3 ideas:
- 1. Make a large subroutine for each action_N and then just calling the
individual smaller subroutines inside action_N subroutine. I prefer this option as
I think it'll be easier for me to keep track of after I've forgotten what I've
done in a few years.
- 2. Make each action_N a module.
- 3. Create separate scripts for each action_N.
Thank-you for any insight.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
|
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.