in reply to Re: reference to a subroutine inside a package
in thread reference to a subroutine inside a package

thanks with can i can do the reference, but yes i have to instantiate the class and pass it as an argument (that's not problem, well if you are an OO purist it is)

what i am trying to do is to load references to subroutines in diferent packages, so i process them with the twig_roots attribute of XML::Twig, in my application i represent an XML tag as a package that inherits the standard behaviour from another (the base class of all xml elements of my application). in here i'm kind of confused because i can't pass parameters to the subroutine i'm referencing, so it this subroutine is a class method (it does not recieve a reference to an instance of the class as the first argument), and i don't know if i should create an instance to the class inside this method (i don't want to do this because i think it is kind of dirty).
i don't think this approach is very good but i can't think of another one
thanks


ignorance, the plague is everywhere
--guttermouth

Replies are listed 'Best First'.
Re^3: reference to a subroutine inside a package
by tinita (Parson) on Jun 03, 2004 at 11:27 UTC
    but yes i have to instantiate the class and pass it as an argument (that's not problem, well if you are an OO purist it is)
    why would that be a problem for OO purists?
        $object->$coderef($arg1, $arg2, ...);
    seems to be perfect OO style...

    update: one might think (i thought that too for a while) that only
        $coderef->($object, $arg1, $arg2, ...);
    will work, which, of course, isn't too nice OOP.

      seems to be perfect OO style...

      Because you are used to seeing this. Some OO purists dislike arguments (to methods, not the other kind). They would probably prefer it like this:

              $object->$coderef( $object->$other_coderef_to_access_arg1_through_argn );

      Cheers, Sören

        Some OO purists dislike arguments (to methods, not the other kind).
        that's new to me. i wonder how it's possible to program without arguments.