|
|
| Perl-Sensitive Sunglasses | |
| PerlMonks |
What's the best way to make my script execute different sections without using goto?by gctaylor1 (Hermit) |
| on Feb 24, 2009 at 17:21 UTC ( [id://746054]=perlquestion: print w/replies, xml ) | Need Help?? |
|
gctaylor1 has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks,
My current script looks something like this: 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:
Thank-you for any insight.
Back to
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||||||||||