Hello All ,
Ive been going thru typeglobs again and I ran into this code from Sriram Srinivasan's Advanced Perl programming book
================================================
sub generate_greeting {
my ($greeting) = @_;
sub { print "$greeting world\n";}
}
$rs = generate_greeting("hello"
;
# Instead of invoking it as $&rs(), give it your own name.
*greet = $rs;
greet();
# Equivalent to calling $&rs(). Prints "hello world\n"
=================================================
I think the "Instead of invoking it as $&rs(), give it your own name." has a typo.
Ive read this many times over before I ran the code.
You really cant invoke the anonymous subroutine by
$&rs();
right?
&$rs();
worked for me
Pardon me ...this might appear trivial ....but after a long gap everything looks new to me.
regards
C
"Brahmaiva satyam"
-Adi Shankara (788-820 AD)
Ive been going thru typeglobs again and I ran into this code from Sriram Srinivasan's Advanced Perl programming book
================================================
sub generate_greeting {
my ($greeting) = @_;
sub { print "$greeting world\n";}
}
$rs = generate_greeting("hello"
# Instead of invoking it as $&rs(), give it your own name.
*greet = $rs;
greet();
# Equivalent to calling $&rs(). Prints "hello world\n"
=================================================
I think the "Instead of invoking it as $&rs(), give it your own name." has a typo.
Ive read this many times over before I ran the code.
You really cant invoke the anonymous subroutine by
$&rs();
right?
&$rs();
worked for me
Pardon me ...this might appear trivial ....but after a long gap everything looks new to me.
regards
C
"Brahmaiva satyam"
-Adi Shankara (788-820 AD)