in reply to Re: Re: Re: Can't call method "prepare" on an undefined value
in thread Can't call method "prepare" on an undefined value

I'm using local, so that the variables defined only stay within that procedure. They don't need to be global variables.

As for your suggestion of passing the variable out, that didn't work. I guess that $mwsdbh is not really a scalar. How can I reference it properly?

#!/massyn.pl The more I learn, the more I realize I don't know. Albert Einstein 1879-1955

  • Comment on Re: Re: Re: Re: Can't call method "prepare" on an undefined value

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Can't call method "prepare" on an undefined value
by CountZero (Bishop) on Dec 19, 2002 at 19:37 UTC
    1. As per the Camel Book (3 ed.) p. 994 the local operator is used to localize a global variable within a dynamic scope.

      Use my for local variables whenever you can get away with it. Using local merely gives you a temporary value to a global variable. (the Camel Book (3 ed.) p. 588)

    2. Did you declare $mwsdbh also as a local initially? If you leave the scope it was declared in, it looses its local value.

    3. You can pass anything out to a subroutine: scalars, arrays, hashes, references, ...

      As long as the subroutine reads it back in through @_ in the right order it cannot be the cause of your problem. Can you post your code with the passing of the $mwsdbh variable to the subroutine and the way the subroutine used it?

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law