sub foo {print "world,\n"} my $func_name = "foo"; my $func_ref = \&foo; # Replace foo *foo = sub {print "Hello "}; &$func_name(); $func_ref->();