Here's some test code I threw together. If you want to preserve the other slots, you'll likely have to use Symbol's gensym to make a new typeglob and assign all of the other slots to it, then use it to replace the old symbol. If you're comfortable with the following code, there you go:
#!/usr/bin/perl -w
use strict;
package destination;
package main;
use Test::More 'no_plan';
{
no strict 'refs';
*{'destination::foo'} = sub { 'foo' };
}
is( destination::foo(), 'foo', 'install a sub' );
{
no strict 'refs';
my $d = *{ 'main::destination::' };
delete $d->{foo};
}
ok( ! destination->can( 'foo' ), '... now remove it' );