Hi Chaoui05,
Yes, this approach is going to be a little more code - but only a few lines, depending on the specific case of course. However, as is often the case with such trade-offs, the little bit of time you spend writing a few more lines of code today may be much less than the time spent on debugging issues caused by misuse of global variables or the refactoring of the code as it grows more complex tomorrow.
Hope this helps, -- Hauke D
| [reply] |
Oh yes i understand. Sometimes it's better to spend more time at the beginning..
In any case, we have different approachs in Perl
| [reply] |
Hi Chaoui05,
Sure, and I'd say the best approach depends on various things, such as whether or not I'm confident that the script will stay short enough that using globals (which I've done plenty of times) is acceptable. I just thought I'd use this opportunity to illustrate an approach for more complex scripts.
Regards, -- Hauke D
| [reply] |