# define your hash entry $foo{bar} = sub { print "Hello Perl!\n" }; # note the use of && operator, which will short-circuit # if $foo{bar} is undef. $foo{bar} && $foo{bar}();