in reply to Re: how to assign output of Find() into a variable $
in thread how to assign output of Find() into a variable $

I agree that global variables are almost always undesirable. I do not think that accessing the same variable by reference rather than by name justifies the added complexity. Perhaps it would be better to restrict the scope of the 'global' variable by placing it in a subroutine along with the call to find.
Bill
  • Comment on Re^2: how to assign output of Find() into a variable $

Replies are listed 'Best First'.
Re^3: how to assign output of Find() into a variable $
by GrandFather (Saint) on May 18, 2016 at 21:23 UTC

    Those sort of decision depend a great deal on context. The OP is almost context free so showing the "complex" version provides a robust scale-able pattern and a good starting point for further discussion.

    It's not clear to me how localizing the global (to the callback) variable avoids the need to pass the variable to the callback if the callback is out of line. Obviously if the callback is inline there is no need to pass in the variable and then it really doesn't matter what the scope of the variable is.

    Premature optimization is the root of all job security