in reply to My first Perl module...

In the sub that works you use
$self->{}
explicitly dereferencing the $self reference. In the sub that doesn't work you use
$self{}
which implies that $self is a hash itself and not a reference -- thus making your use strict; complain about an undefined global hash called %self.

As a side note I'd suggest dropping the double quotes in your hash keys -- they're not necessary and they force interpolatin where none is necessary (even if you needed interpolation you wouldn't need quotes there).

Replies are listed 'Best First'.
Re: Re: My first Perl module...
by Anonymous Monk on Nov 17, 2000 at 14:24 UTC
    Hmm, so is defining %self globally the answer? It doesn't seem like it should be to me, but I'll of course defer to your judgement. :)
      No, defining %self is not the answer (and I don't think snax said it was). You should use a valid syntax for references, like $self->{"_ldap"}, to refer to the anonymous hash that $self refers to.

      /brother t0mas
      t0mas is correct -- I don't suggest that you declare %self globally, especially since it really won't do what you want it to do :)

      Check out perlman:perlref for more details on using references, and poking through perlman:perlobj and/or perlman:perltoot is probably a good idea, too.

      $hash{key} refers to the 'key' element of the hash called %hash. $hash->{key} refers to the 'key' element of the hash referred to in the reference $hash. $hash has nothing to do with %hash. Check out perlref and other documentation mentioned by others.