http://www.perlmonks.org?node_id=266334

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am wondering if it is possible to scope an entire namespace. I have an application I am trying to use under mod_perl. One of the objects dynamically require/do's a file that containes serialized data. This data is then used by assigning from the name space to an objects instance data. This happens like so:


eval "require './data_to_import.dat'" if -f './data_to_import.dat'; $self->{imported_data} = $foo_name_space::data unless $@;

This works great until it's tried under mod_perl. Data is being shared and is showing up where it's not supposed to. Now I can't redesign the whole application, but the speed boost of mod_perl is too enticing to say 'forget it'. Is there a way to do something along the lines of the following (I am aware this doesn't work):

{ local *foo_name_spane::data; eval "require './data_to_import.dat'"; + $self->{imported_data} = $foo_name_space::data unless $@; }