For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > June 2005 > blessing a class









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author blessing a class
Radhika

2005-06-08, 3:57 am

I am learning about perl modules and am having a little trouble
understanding the "blessing" of an object. For instance:
bless($self, $type);
What does this do?

Thanks,
rs.

--
It's all a matter of perspective. You can choose your view by choosing
where to stand.
Larry Wall
---
Randal L. Schwartz

2005-06-08, 3:57 am

>>>>> "Radhika" == Radhika <radhika@88thstreet.com> writes:

Radhika> I am learning about perl modules and am having a little trouble
Radhika> understanding the "blessing" of an object. For instance:
Radhika> bless($self, $type);
Radhika> What does this do?

$ perldoc -tf bless

bless REF,CLASSNAME
bless REF
This function tells the thingy referenced by REF that it is now
an object in the CLASSNAME package. If CLASSNAME is omitted, the
current package is used. Because a "bless" is often the last
thing in a constructor, it returns the reference for
convenience. Always use the two-argument version if the function
doing the blessing might be inherited by a derived class. See
perltoot and perlobj for more about the blessing (and blessings)
of objects.

Consider always blessing objects in CLASSNAMEs that are mixed
case. Namespaces with all lowercase names are considered
reserved for Perl pragmata. Builtin types have all uppercase
names, so to prevent confusion, you may wish to avoid such
package names as well. Make sure that CLASSNAME is a true value.

See "Perl Modules" in perlmod.

Now, what's your first question after having read that?

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
Eric Walker

2005-06-08, 3:57 am

On Tuesday 07 June 2005 12:44 pm, radhika wrote:
> I am learning about perl modules and am having a little trouble
> understanding the "blessing" of an object. For instance:
> bless($self, $type);
> What does this do?
>
> Thanks,
> rs.
>
> --
> It's all a matter of perspective. You can choose your view by choosing
> where to stand.
> Larry Wall
> ---

I am a newbie myself but as far as I know blessing actually registers the
current object with perl. This allows for inheritance and instances of the
object to be created. Also for methods to act on this newly
registered(blessed) object.

PerlNewbie....
Owen

2005-06-08, 3:57 am

On Tue, 7 Jun 2005 14:44:29 -0400 (EDT)
"radhika" <radhika@88thstreet.com> wrote:

> I am learning about perl modules and am having a little trouble
> understanding the "blessing" of an object. For instance:
> bless($self, $type);
> What does this do?



Have a look at Randal's

http://www.stonehenge.com/merlyn/UnixReview/col52.html




Owen
Radhika

2005-06-08, 8:56 pm

Thank you all for your inputs.
I am busy reading all the material. I am sure I will have questions.

-rs


--
It's all a matter of perspective. You can choose your view by choosing
where to stand.
Larry Wall
---
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com