Off topic but cc'd to the list to save dupes!... Anthony Gardner wrote: It simply creates a sub but just doesn't give it a name, and it has a 'return value' which is a code ref. Try to imagine normal subs as simply assigning a code ref to a constant name (confused yet?)Well, it wasn't obvous to me. So, what does sub{} actually do? Right, forget what you learned in C++ classes... in Perl an object method is simply a sub with the object ref passed automatically as the first parameter, sobut my problem involved a ref to a class and a function name which I haven't seen documented. $self->method($arg) is the same as &method($self,$arg) Time to RT(F)M at this point, start with 'man perltoot' :) Once you realise how simply perl handles subs, objects etc it all becomes clear and easy. hope this helps, John Unless s.o. can point me to the right place.Thanks for the tip and any more info on what is actually happening when we invoke sub{} would be great. -Ants --- John ORourke <[EMAIL PROTECTED]> wrote:Anthony Gardner wrote:and I need a code ref. The thing is, I can't make a code ref out of .... $self->method_to_invoke( $arg1, $arg2 );I'm going to get into trouble for stating the obvious here but have you tried: $code_ref = sub { return shift->method_to_invoke( @_ ) } (ie. create a new anonymous method which is just a wrapper for your method - if your method is really quick and you're iterating *lots* it may affect timing a little) John___________________________________________________________ How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com |