in reply to Best practices with globals and subroutine arguments

I'd probably use "global" variables.

I wouldn't say on Perlmonks I'd be using "global variables". Instead, I'd label those variables class instance variables, and call the class they're defined in a "singleton object". Then non of the "global variables are bad" triggers will fire; instead, people will think the world of you. But except for the labels, there's no difference.

  • Comment on Re: Best practices with globals and subroutine arguments

Replies are listed 'Best First'.
Re^2: Best practices with globals and subroutine arguments
by Anonymous Monk on Jun 07, 2010 at 09:01 UTC
    I'd probably use "global" variables. I wouldn't say on Perlmonks ...

    JavaFan, today you have

    Experience:  	11072
    Level:	Prior (17)
    Writeups: 	2074 
    You obviously know about scoping, about the best practices and when its ok to break them; you're an expert.

    How often do you use globals to avoid de-referencing references, and does that simplify things considerably?

      The OP indicates the variables are not modified inside the subroutines. For the POV of the subroutine, the variables might as well be constants.

      How often do you use "global" constants, and does that simplify your code instead of passing them around in each subroutine call?

      You obviously know about scoping, about the best practices and when its ok to break them; you're an expert.
      I find this a bit insulting for the OP. It suggests the OP is an idiot, or at least needs to program with his training wheels on. I do not with to make such assumptions.