#!/usr/bin/perl -w use strict; { my $const_return = 'BEGIN { eval "sub HAS () { return 1 }" }'; my $const_noreturn = 'BEGIN { eval "sub HAS () { 1 }" }'; my $const_use = 'use constant; BEGIN { constant->import( HAS => 1 ) }'; my $paren = 'print HAS;'; my $noparen = 'print HAS();'; print( 'return, with parens ', run($const_return, $paren ), "\n", 'return, without parens ', run($const_return, $noparen), "\n", 'noreturn, with parens ', run($const_noreturn, $paren ), "\n", 'noreturn, without parens ', run($const_noreturn, $noparen), "\n", 'use, with parens ', run($const_use, $paren ), "\n", 'use, without parens ', run($const_use, $noparen), "\n", ); } sub run { my($code) = join ' ', @_; my @normal = qx{perl -wle \Q$code\E }; my @deparse = qx{perl -MO=Deparse -wle \Q$code\E 2>/dev/null}; chomp(my $normal_output = $normal[-1]); chomp(my $deparse_output = $deparse[-1]); return join ' ', $normal_output, $deparse_output; }