Hi Marcos.
First let's remove some fog from your code. Your anonymous subroutine
sub {$_ = 5;}
is returning the value '5' because that's the value of the assignment
operator '='. The assigment to $_ is serving no useful purpose as
$_ isn't used anywhere else. So we can reduce this to
sub {
On Tue, Dec 09, 2003 at 09:14:52AM +0100 [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'
>
> This don't work
> perl -e 'sub a{print(&{$_[0]}, "/
;});
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
Subjec
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