in reply to How to alias a whole namespace to another namespace (in this case main::)

This should work:
no strict refs; *{$target_package . "::"} = *{$source_package . "::"};

For example:

*{"main::"} = *{"foo::"};

Replies are listed 'Best First'.
Re^2: How to alias a whole namespace to another namespace (in this case main::)
by aufflick (Deacon) on Nov 15, 2004 at 05:18 UTC
    sub foo::bar {print "bar\n"} *{"main::"} = *{"foo::"}; bar();

    Results in:

    Modification of a read-only value attempted at - line 2.

    And I want to add to main, not completely replace it.

      Modification of a read-only value attempted

      Sorry, I'd never tried aliasing over main that way; I guess the root package name is more special than the others.