#!/usr/bin/perl use strict; use Symbol qw(delete_package); require 'bob.pm'; our $ref = $::{'bob::'}; print 'A ', \${$ref->{bob}}, ' ', ${$ref->{bob}}, "\n"; print 'A ', \$bob::bob, ' ', $bob::bob, "\n"; delete_package('bob'); print delete $INC{'bob.pm'}, "\n"; $ref = $::{'bob::'}; require 'bob.pm'; $ref = $::{'bob::'}; for (keys %$ref) { no strict 'refs'; *{"bob::$_"} = \${$ref->{$_}}; } print 'B ', \${$ref->{bob}}, ' ', ${$ref->{bob}}, "\n"; print 'B ', \$bob::bob, ' ', $bob::bob, "\n"; *bob::bob = \${$ref->{bob}}; print 'C ', \${$ref->{bob}}, ' ', ${$ref->{bob}}, "\n"; print 'C ', \$bob::bob, ' ', $bob::bob, "\n"; __END__ package bob; our $bob = "This is package bob"; printf "loading bob.pm: %s\n", $bob; 1; __OUTPUT__ loading bob.pm: This is package bob A SCALAR(0x816a2c8) This is package bob A SCALAR(0x816a2c8) This is package bob loading bob.pm: This is package bob B SCALAR(0x816a5a4) This is package bob B SCALAR(0x816a2c8) C SCALAR(0x816a5a4) This is package bob C SCALAR(0x816a5a4) This is package bob