1. Make the bodies of my if statements into procedures.
2. Have, at the very beginning of my program, my if statements. Rather than have them execute the procedures, have them build an array of procedure references.
3. In the body of my script, for each row of data, call each procedure in the array.
Instead of having following code:
I could have for example C B A R if statement in the while loop because the user selects only CBAR.while(<FH>){ if($_ =~ C B A R){ do something This bit is not the same for all elements and it is average 100 +lines long } if($_ =~ Q U A D){ do something This bit is not the same for all elements and it is average 100 +lines long } if($_ =~ C R O D){ do something This bit is not the same for all elements and it is average 100 +lines long } if($_ =~ C B E A M){ do something This bit is not the same for all elements and it is average 100 +lines long } if($_ =~ C E L A S 1){ do something This bit is not the same for all elements and it is average 100 +lines long } ... }
while(<FH>){ if($_ =~ C B A R){ do something This bit is not the same for all elements and it is average 100 +lines long } }
In reply to How can I create a procedure by ozgurp
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |