http://qs321.pair.com?node_id=919963


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:
hisham@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
check %perldoc perlsub


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