#!perl use strict; use warnings; my $x = shift; my $sub_name = $x ? 'foo' : 'bar'; eval "*$sub_name = sub { print \"Hello!\n\" };"; foo();