Re: Code Refs

2005-09-16 Thread Jeff
> This is just Perl related but as it's running under > mod_perl, I'm sure you lot won't mind ;) > > I'm trying to benchmark a piece of code with timeit > 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've tried various

Re: Code Refs

2005-09-16 Thread Damyan Ivanov
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Anthony Gardner wrote: > This is just Perl related but as it's running under > mod_perl, I'm sure you lot won't mind ;) > > I'm trying to benchmark a piece of code with timeit > and I need a code ref. The thing is, I can't make a > code ref out of ...

Re: Code Refs [OT]

2005-09-16 Thread John ORourke
Off topic but cc'd to the list to save dupes!... Anthony Gardner wrote: Well, it wasn't obvous to me. So, what does sub{} actually do? 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 assignin

Re: Code Refs

2005-09-16 Thread Anthony Gardner
Well, it wasn't obvous to me. So, what does sub{} actually do? I'm clear about ... my $code_ref = sub{ print "sth" } as I've wrapped some perlcode in a code ref ;) I'm clear about sub func_to_invoke() { print "sth" } my $code_ref = \&func_to_invoke() but my problem involved a ref to a

Re: Code Refs

2005-09-16 Thread John ORourke
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 n