in reply to Redoing a script

There is a lot of fairly dodgy code in there. Nothing really terrible, but lots of sloppy coding like several subs where the only difference is in variable names, or the use of prototype subs that would cause the code to fail except that the subs are defined after their first use so the prototypes are ignored (it's not important that you understand what that means btw). To be fair there is some good code there too, but it would be hard for a newbie to pick what is good and what is bad. With a good tidy up I'd expect that code to reduce to about 2/3 of its current size and to become easier to understand too.

If you have the option I'd suggest you start from scratch for the new project and come back to PerlMonks to ask questions when you get stuck. You aren't going to learn a lot that is good working from the code you have shown us. Unless someone provides a complete solution for you, it'll probably be quicker to dump this code and start over for the new task. If you do, please come back to have it critiqued so we can help you learn appropriate Perl coding habits.

True laziness is hard work

Replies are listed 'Best First'.
Re^2: Redoing a script
by Marshall (Canon) on Feb 15, 2012 at 14:31 UTC
    I think that you are being too kind to the original code. I figure that it is more than "fairly dodgy". The idea that the code could be reduced to only 2/3 of original size is a vast understatement!

    This is a case where the general implementation approach of the code is just so far wrong, that telling the OP to study more won't help. The OP is trying to modify very poorly written code from another student.

    "studying crap" is just going to result in "more crap".

    I think this is case where showing some Monk level code is appropriate and I tried to do that. The OP has gotten some enormous hints about what to do.

    I hope that the OP uses the code given and comes back with better questions.