Re: Inherit a database connection object



On 6/24/07, Patrik Hasibuan <patrikh@xxxxxxxxxxxxxxxxxxxxx> wrote:

I want to write once a script as a part of building a connection to my MySQL
DB server. The parts only use a kind of vabiable such as "$dbh". Is it possible?

It's possible. In fact, that's what most of us do with objects.

#!/usr/bin/perl -w

That's a good start. You could also use "use warnings" instead of -w,
and adding "use strict" will prevent some common mistakes.

use strict;
use warnings;

use iterdir;

What's this? Module names in all lower case are reserved for pragmas.
In the privacy of your own home directory, of course, you can name
things whatever you want. But normal modules, and the package names
they use, begin with a capital letter.

Can't call method "prepare" on an undefined value at iterdir.pm line 22.

That means that the expression to the left of "->prepare" near line 22
turned out to be undef instead of an object.

Please tell me how a class inherits connection object to the another class.

Perl objects use the @ISA mechanism, documented in the perlobj manpage.

http://search.cpan.org/~nwclark/perl-5.8.8/pod/perlobj.pod

But it may help to start in the barnyard:

http://search.cpan.org/~nwclark/perl-5.8.8/pod/perlboot.pod

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training
.



Relevant Pages

  • Re: stalling server client program
    ... use strict; ... use warnings; ... my $port = 12345; ...
    (comp.lang.perl.misc)
  • Re: stalling server client program
    ... use strict; ... use warnings; ... my $port = 12345; ...
    (comp.lang.perl.misc)
  • Re: Problem with IO::Socket
    ... > use strict; ... One should probably check for success: ... > is supposed to output the current date of that server. ... > should print the welcome message of the smtp-server on mail.motmail.com ...
    (comp.lang.perl.misc)
  • IO::Socket server
    ... use strict; ... Proto => 'tcp'); ... What I want it to do is have the server on one computer and the client ...
    (perl.beginners)
  • IO::Socket server
    ... use strict; ... Proto => 'tcp'); ... What I want it to do is have the server on one computer and the client ...
    (comp.lang.perl.misc)