On Fri, 2006-23-06 at 13:01 -0400, Muttley Meen wrote:
> All this if foo has the prototype
> sub foo(&$)
> 
> The question that I have is why isn't it possible to have
> the block reference as the second parameter, so foo would be called as :

Don't use prototypes. They were design for other things than what you
want to do. 99.9% of everything you are likely to do does not need them.

To pass a reference of a subroutine to another:

  foo( \&other_sub, $text );

To pass an anonymous subroutine:

  foo( sub { print "in anonymous sub\n"; }, $text );

To save them in a variable:

  my $other = \&other_sub;
  my $anony = sub { print "in anonymous sub\n"; };


-- 
__END__

Just my 0.00000002 million dollars worth,
   --- Shawn

"For the things we have to learn before we can do them, we learn by doing them."
  Aristotle

* Perl tutorials at http://perlmonks.org/?node=Tutorials
* A searchable perldoc is at http://perldoc.perl.org/



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to