>From the manpage "This function (bless) tells the thingy referenced by
REF that it is now an object in the CLASSNAME package".
The "thingy" is the scalar, array or hash we decide to use to represent
our object, in your case (as in most) a hash was chosen.
If you look at the results of Dumper you'll see that it looks just like
a hash but is tagged as a MARS::Config object.
You can even use it just like an ordinary hash reference but you should
really develop some instance methods see perlobj, et al.
> could you pleasde explain your new() block for me ? i don't know bless... i
> would be greate if you put a explaining comand to these lines.
>
> sub new {
> my $class = shift;
when we call MARS::Config->new() the sub new is passed the string
'MARS::Config' as its first argument.
> my $self = bless {}, ref($class)||$class;
This says bless this anonymous hash {} into the class $class.
The ref($class) is to catch the case where we say $CONFIG->new instead
of MARS::Config->new.
$self is now an object reference and we can use its methods and
attributes.
> $self->init();
Here we call the object's init() method
> return $self;
Finally, we return the initialtized object to the caller.
Note that we don't need to explicitly tell init which object instance we
are working on. The object knows this and passes it to init as the
first argument - it is blessed!
Read perlboot, perltoot, perlobj, perlref, etc.
--
Simon Oliver
_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web