in reply to Simplify code in Perl with "unless" condition
When you say you "find it's too heavy", what makes you think this?
Where in your code is a loop and what do you want to remove?
Note that you can always replace unless(...) by if( not ... ).
Personally, I have the impression that it is not you who finds that code "too heavy" but your teacher or supervisor. Maybe you should go to them and ask them more about what they don't like with your code. Maybe they suggested that you replace the three unless statements with a loop.
If you want to use a loop, I suggest you first print out the three statements and mark with a text marker in one colour the things that are identical between the three statements and then with a text marker of a different colour the things that are different between the three statements. Then you ideally review your course material on loops and find out how you can use a loop to go over the things that are the same and apply the things that need to change for each statement.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Simplify code in Perl with "unless" loop
by Chaoui05 (Scribe) on May 27, 2016 at 16:19 UTC |