On Sat, 24 Apr 2010 10:06:37 -0500, Harry Putnam wrote:

> Harry Putnam <rea...@newsguy.com> writes:
> 
> 
>> However, using your suggestion:
>>   > $code->($var1, $var2);
> 
> Something I forgot to ask about that.
> 
> What if more than 1 of referenced sub routines needed vars passed in but
> the needed vars were not the same?
> 
> I'm guessing that using $code->() is not such a good idea.  Whatever
> data any subroutines may need, should have been supplied before the
> `dispatch table' is called.

You are looking for a closure.  Just make a reference to a subroutine that 
does what you want, including passing arguments to the subroutine you 
thought you wanted to call in the first place:

$code = sub { whatever( $arg1, $arg2 ) };

-- 
Peter Scott
http://www.perlmedic.com/     http://www.perldebugged.com/
http://www.informit.com/store/product.aspx?isbn=0137001274
http://www.oreillyschool.com/courses/perl1/

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to