in reply to dynamically renaming a package?

Maybe something like this  (it doesn't exactly rename the package, but rather just copies its symbol table hash):

#!/usr/bin/perl package Foo; sub bar { print "bar() called.\n" } package main; BEGIN { %{*NewFoo::} = %{*Foo::} } NewFoo::bar(); # calls Foo::bar();

or without BEGIN, in which case you need to postpone the compilation of NewFoo::bar() until runtime using eval:

... %{*NewFoo::} = %{*Foo::}; eval q|NewFoo::bar()|; # calls Foo::bar();