#!/usr/bin/perl -w use strict; sub do_this { print "doing this!\n" } sub do_that { print "doing that!\n" } my $code = get_coderef('do_this'); $code->(); $code = get_coderef('do_that'); $code->(); $code = get_coderef('do_nothing'); if (defined($code)) { $code->(); } else { print "Not defined!\n"; }