> > I'm starting to get into OO programming with Perl and
> > have a question.
> >
> > As I understand it with OO - you create an object and
> > then do something to it.
> >
> > I have a list of values in an array and I wish to do
> > the same "something" to all of them.
> >
> > Do I need to create an object for each value in the
> > array and then do something to all of them ?
> >
> > Or can I create 1 object and do the "something" to all
> > the values from within that 1 object ? (if that makes
> > sense !)

Either, really, depending what you want to do.

If the array is a part of your object (a field or a
slot of the object), then you will probably write a
method of the object to handle that field: say your
object is a car, with a list of four elements representing
wheels, you may have a method named 'turn' which
you apply to all wheels -- and probably a method
'turn wheels' which takes no parameters (other than
the object...) to perform the 'turn' method upon all
wheels.

On the other hand, you may have an array of values which
you wish to process with an object: say you have
four HTML pages, each of which you wish to parse with
a parser such as HTML::TokeParser - then you'll have
to create a new parser (an 'instance' of the parser) for
each HTML page.

So, if you'd like to give a more concerete example of
what you're doing....!

Hope it helps,
lee


_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to