Title: RE: OO question

I think the answer is yes, you can do it all in one process. If I understand you correctly you want to know whether you can do something like this:

### BEGIN
use Nathan::Rimmers::Module;
my %array;
my $do = new Nathan::Rimmers::Module;
my $result = $do->something(%array);
# Do something with $result
### END


versus having to do it like so:


### BEGIN
use Nathan::Rimmers::Module;
my %array;
my $do = new Nathan::Rimmers::Module;
foreach my $key (keys %array)
{
        my $result = $do->something($array{$key});
        # Do something with $result
}
### END



Either approach can work. It just depends on what you're trying to do. Might be a good reason to 'use Benchmark' and see which gives the faster (better?) result (I'm betting on the former). Or am I misunderstanding your question?

-Pete


> -----Original Message-----
> From: Nathan Rimmer [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, July 30, 2002 10:28
> To: [EMAIL PROTECTED]
> Subject: OO question
>
>
> 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 !)
>
>
> Thanks,
> Nathan
>
> __________________________________________________
> Do You Yahoo!?
> Everything you'll ever need on one web page
> from News and Sport to Email and Music Charts
> http://uk.my.yahoo.com
> _______________________________________________
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>

Reply via email to