in reply to Understanding and building modules

$auth = new Mapps::Auth->auth($uname, $passwd); Just guessing, but this code looks really, really wrong. I'm not sure exactly what it'll do (my best guess is it calls the method "new" on the return of auth->auth, but indirect function calls are funky).

Try changing it to two lines and see if it fixes your problems:
$auth = Mapps::Auth->new(); $auth->auth($uname, $passwd);
Or alternatively Mapps::Auth->new()->auth($uname,$passwd);

Replies are listed 'Best First'.
2Re: Understanding and building modules
by jeffa (Bishop) on Apr 03, 2004 at 22:24 UTC
    And while we are at it, change:
    sub auth { my ($uname, $passwd, $dbsecret, $salt); $uname = shift; $passwd = shift; ... }
    to
    sub auth { my ($self, $uname, $passwd) = @_; my ($dbsecret, $salt); ... }
    or the method call will not work. Here is a little test script i came up with. Looks like the problem isn't in the constructor as i originally suspected, but instead in that wacky method call/instantiation.
    ref new Foo or warn "example 1 is not an object\n"; ref new Foo->foo or warn "example 2 is not an object\n"; package Foo; sub new { bless {} } sub foo { "foo" }

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)