in reply to Re^2: Recover a variable from a function
in thread Recover a variable from a function

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

  • Comment on Re^3: Recover a variable from a function

Replies are listed 'Best First'.
Re^4: Recover a variable from a function
by Chaoui05 (Scribe) on May 19, 2016 at 08:40 UTC
    Oh yes i understand. Sometimes it's better to spend more time at the beginning.. In any case, we have different approachs in Perl

      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

        I will try to have this in a corner of my head. Thanks !