| Jonathan Lang 2007-05-31, 6:59 pm |
| Alma wrote:
> Hi ,
>
> Urgent help.
>
> I have written 2 modules one abc.pm & xyz.pm (admin modules).
>
> abc.pm
> --------------------------------------
> my $databasehandle;
Note that this establishes a single $databasehandle for every object
of type 'abc' that you create; it does not create a separate one for
each object.
> sub new($){
>
> my ($self,$usr,$pwd) = @_;
Again, you have a signature problem. 'sub new($)' says that 'new'
will take a single scalar as a parameter; as such, @_ will only ever
have one value in it: $usr and $pwd will always be set to null.
Also, read up on the syntax of 'bless' a bit more. IIRC, saying
'bless $self;' is not enough.
> $usr||= "test";
> $pwd ||= "test123";
....and thus $usr and $pwd will always equal "test" and "test123",
respectively.
> sub DESTROY(){
> my $self;
> $self->disconnect();
> }
You never set $self to anything. Change the '()' in 'sub DESTROY()'
to '($)', or remove them altogether; then change 'my $self;' to 'my
$self = shift;' or 'my ($self) = @_;'
--
Jonathan "Dataweaver" Lang
|