#!/usr/bin/perl -w use strict; sub my_sub { print "This is the first subroutine called my_sub\n"; } my $soft_sub = 'sub { print "This is the redefined subroutine.\\n"; };'; my $my_sub = "The scalar with the same name.\n"; my $sub_ref; eval "\$sub_ref = $soft_sub"; my_sub(); print "$my_sub\n"; undef &{ *my_sub{CODE} }; *my_sub = $sub_ref; my_sub(); print $my_sub;