in reply to Re: Re: How to use variables from other package?
in thread How to use variables from other package?

Exporting the variables will lead to an error thrown for any typo under strict as well, and it is always thrown at compile time, while that isn't guaranteed for the function.

Makeshifts last the longest.

  • Comment on Re^3: How to use variables from other package? (guaranteed compile time error)

Replies are listed 'Best First'.
Re: Re^3: How to use variables from other package?
by Necos (Friar) on May 01, 2003 at 15:21 UTC
    Good point Aristotle. The only point I was trying to make is that he could try exporting the variable value (since the name is unimportant) via function/method. It seems the safest way considering that you don't always want to step on someone else's toes with variable names.

    I've always been wary of things like  $pkg::var. If I can avoid it with the use of a function, I do. I never liked trying to remember all of the package variables from a package I didn't write. If you're using/writing a module that is OO-based, you should provide a method for getting the value of a certain attribute. And, even if you're writing something non-OO, you should _STILL_ provide some way of getting to a value without making your user remember a particular variable name (of course the exceptions to that rule are the common names, like $VERSION). At least, that's what I've always felt.

    Theodore Charles III
    Network Administrator
    Los Angeles Senior High
    email->secon_kun@hotmail.com
    perl -e "map{print++$_}split//,Mdbnr;"
      It boils down to remembering a function name instead of a variable name though, so I don't know where the win is. The value can't be altered, true.

      Makeshifts last the longest.