use constant foo => 1; sub bar { $_[0] } print "ok\n" if is_constant('main::foo'); print "ok\n" unless is_constant('main::bar');