Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re: Reply to replies and updateby bigmacbear (Monk) |
on Aug 10, 2006 at 02:18 UTC ( [id://566530]=note: print w/replies, xml ) | Need Help?? |
It appears you are trying to make one subroutine do the work of several, and distinguishing which by the number and content of your "subargs" (which I will call "parameters" to your sub, to distinguish them from the command line arguments in @ARGV). This one sub does five different things:
I would structure this monster as a number of different subroutines. Basically, get rid of the second parameter to your catch-all sub; then write one subroutine to do each of the five tasks above, using the sub's name to convey the same information. The first sub, however, is probably better written right into your mainline code, as it operates on the global @ARGV -- for now. The second sub would be called in turn by the following two or three. Furthermore, I wouldn't necessarily rely on the fact that the list you are searching for resides in @ARGV, for the simple reason that a real program will very likely accept its data from a file or other source rather than as discrete command-line arguments. Copy the arguments into a normal array and pass a reference to this array to the task subroutines above. If you have no idea what I mean by references at the moment, click or run perldoc perlreftut. Oh, and your uninitialized variables problems will pretty much Go Away if you do two things:
You're getting there, just not quite there yet.
In Section
Seekers of Perl Wisdom
|
|