in reply to Ternary Operator with Subroutine
When you assign to a reference a value (in this case an anonymous sub), dereference that reference to access its value:
David R. Gergen said "We know that second terms have historically been marred by hubris and by scandal." and I am a two y.o. monk today :D, June,12th, 2011...
check %perldoc perlsubhisham@bioslayer:~$ perl - my $subref = sub{print 'a',"\n";}; (my $test)?print 'c' : $subref->(); #dereference with infix arrow oper +ator __END__ a hisham@bioslayer:~$ perl - my $subref = sub{print 'a',"\n"}; (my $test)?print 'c' : &{$subref}; #dereference with &{} __END__ a
David R. Gergen said "We know that second terms have historically been marred by hubris and by scandal." and I am a two y.o. monk today :D, June,12th, 2011...
|
---|
In Section
Seekers of Perl Wisdom