in reply to Return value of a sub

You're defining an anonymous sub, but not calling it. Try
(sub {my $str = "aaa"; $str =~ m/abc/})->() ? print "sub ok\n" : print + "sub fail\n"; #sub fail

Replies are listed 'Best First'.
Re^2: Return value of a sub
by AnomalousMonk (Archbishop) on Jul 07, 2009 at 19:22 UTC
    Or even, with fewer parens:
    >perl -wMstrict -le "sub { print $_[0] }->('hi')" hi