Re: How to pass a block of code, as a parameter to function.

2006-06-23 Thread Mr. Shawn H. Corey
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

Re: How to pass a block of code, as a parameter to function.

2006-06-23 Thread Muttley Meen
On 6/23/06, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote: On Fri, 2006-23-06 at 17:19 +0300, Muttley Meen wrote: > I searched around for a construct to permit for a block > of code to be passed as parameter, but with no success. That's because you can't pass a block of code, you can only pass a

Re: How to pass a block of code, as a parameter to function.

2006-06-23 Thread Mr. Shawn H. Corey
On Fri, 2006-23-06 at 17:19 +0300, Muttley Meen wrote: > I searched around for a construct to permit for a block > of code to be passed as parameter, but with no success. That's because you can't pass a block of code, you can only pass a reference to a block of code, or the text that can be compil

RE: How to pass a block of code, as a parameter to function.

2006-06-23 Thread Jeff Peng
Hello, You maybe want to pass a subroutine's reference to another subroutine.I would modify your codes as follow: use strict; sub foo { my $p1 = shift ; my $p2 = shift ; print "Param1 = $p1\n" ; &$p2 ; } sub bar { print "hello\n"; } foo("test",\&bar); It execute and get the resu