Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: Method Calls on multiple objects

by DamnDirtyApe (Curate)
on Mar 27, 2004 at 01:58 UTC ( #340192=note: print w/replies, xml ) Need Help??

in reply to Method Calls on multiple objects

Nice module, L~R, but I'm just not seeing how this is inherently better than using what Perl already gives you.

#! /usr/bin/perl use strict; package Dog; sub new { my $class = shift; my $self = {}; return bless $self, $class; } sub bark { print "Woof!\n"; } package main; my $fido = Dog->new(); my $woofy = Dog->new(); $_->bark for ( $fido, $woofy );

Is this not just as effective? Or am I missing something?

Those who know that they are profound strive for clarity. Those who
would like to seem profound to the crowd strive for obscurity.
            --Friedrich Nietzsche

Replies are listed 'Best First'.
Re: Re: Method Calls on multiple objects
by Limbic~Region (Chancellor) on Mar 27, 2004 at 14:48 UTC
    Or am I missing something?
    Not really. You would have to modify it only slightly to allow argument passing. The big difference is that with:
    $obj_merged->bark( 'mailman' );
    You get the benefit of not having to remember how many/which objects (which could be of different classes) are in the merged object. It also becomes a heck of a lot easier depending on how many times you want to bark at the moon. This is why I do not think my second example would be desireable to the person asking either.

    Keep in mind I am not suggesting a new module for CPAN by any stretch of the imagination - just something to help someone who asked.

    Cheers - L~R

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://340192]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2021-10-18 08:06 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (73 votes). Check out past polls.