in reply to Running a Sub for a Text File
Here's where I would start:
First and most important: insert the line
use strict;
near the top of your code. You do declare some variables, but you also have a number of cases where variables spring into existance without warning.
As others have suggested, use meaningful variable names. This will help us see what is happening and will also help you avoid slip-ups with a program of this size where you have a fair number of values floating around.
Explicitly pass the values needed in each sub rather than depending on grabbing them from global variable space. This will go a long way toward helping manage what is happening with your various values.
Were you aware that you have built your subs to return values but you are not doing anything with those returned values? Perhaps you are assuming that they are returned without your explicitly capturing them where the sub is called.
Give these and the other suggesions in the other responses a try and I think you will be able to get more control over what is happening in your code.
Actually encouragement and congratulations are in order. You have advanced to the point that you are grappling with a problem that is complex enough that the quick-and-dirty approach no longer works. A wee bit of discipline at this point will allow you to make very effective use of the skills you have already mastered as you attack larger, more challenging problems.
Cheers,
dvergin
|
|---|