probably what I need is something about 'call back'

Another example inside one script.

this works:
use Data::Dumper;
sub a {
    return Dumper(&{$_[0]});
}
print(a sub {$_ = 5;});


This also works:
use Data::Dumper;
sub a(&) {
    return Dumper(&{$_[0]});
}
print(a {$_ = 5;});


This no longuer works
use Data::Dumper;
sub a {
    return Dumper(&{$_[0]});
}
print(a {$_ = 5;});



Is there some documentaction about this magic?

MArcos
-----Original Message-----
From: drieux [mailto:[EMAIL PROTECTED]
Sent: Tuesday, December 09, 2003 9:39 AM
To: Perl Perl
Subject: Re: passing code inside function



On Dec 9, 2003, at 12:14 AM, [EMAIL PROTECTED] wrote:

> I would like to read something about passing code inside function. 
> Lets say
> that:
>
> This works:
> perl -e 'sub a(&){print(&{$_[0]}, "/n"};$_=0; a {$_++} foreach 1..100'

what you might want to think about is trying
that as 'code' rather than as a command line gambit.

What you seem to be interested in is doing what is
elsewhere known as a 'call back' - and one of the
better places to peek would be in

        perldoc -m File::Find

to look at the actual implementation in the
module,

        perldoc File::Find

to look at the POD about the module.

HTH.


ciao
drieux

---


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


-- 
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