Etienne, We all love the OO hype letters, but first it's the offtopic
question, second it's the FAQ question. You can hunt for luck at the perl
newsgroup or other perl generic list. But save your time and frustration
-- read some books, for example 'Object Oriented Perl' by Domian and 'Perl
CookBook' by Tom and Nathan, and of course the perl manpages (hint:
perldoc perl)
> hi all,
>
> i'm starting out doing some Object Oriented programming with mod_perl
> and I define one object like this:
>
> sub new {
> my $self = shift;
> my $type = ref($self) || $self;
>
> ## bless our object into the class and return it
> return bless {
> first_name => '',
> last_name => '',
> email_address => '',
> @_
> }, $type;
> }
>
> sub AUTOLOAD {
> my $self = shift; ## grab the object we're being called on
> my $type = $self || ref($self); ## get the object type
>
>return if $AUTOLOAD =~ /^DESTROY$/;
>
> my $name = $AUTOLOAD;
>
> $name =~ s/^.*://;
>
> unless( exists $self->{$name} ) {
> croak "Error: Can't access field '$name' in object of class
> $type";
> }
>
> if (@_) {
> return $self->{$name} = shift;
> } else {
> return $self->{$name};
> }
> }
>
> ## more functions ##
>
> Let's say this object is called SomePerson, and I create this object in
> one of my cgi scripts, like so (image SomePerson is part of package
> People):
>
> $some_person = People::SomePerson->new;
>
> how do I change the first_name, last_name, email_address variables?
> Would it be like this, if I'm doing it from inside the SomePerson
> object:
>
> $self->{first_name} = "Etienne";
>
> and like this from a regular cgi script:
>
> $some_person->first_name = "Etienne";
>
> or how?
>
> Thanks in advance,
>
> Etienne
>
___
Stas Bekmanmailto:[EMAIL PROTECTED] http://www.stason.org/stas
Perl,CGI,Apache,Linux,Web,Java,PC http://www.stason.org/stas/TULARC
perl.apache.orgmodperl.sourcegarden.org perlmonth.comperl.org
single o-> + single o-+ = singlesheavenhttp://www.singlesheaven.com