sharing big global hash and objects

[prev] [thread] [next] [Date index for 2005/02/17]

From: Barksdale, Ray
Subject: sharing big global hash and objects
Date: 19:56 on 17 Feb 2005
I have a large structure loaded from a db table that contains parameter
values.
The structure looks something like following (please excuse formatting, MS
lookOut)

my $hash = {
	 table1 => {
		field1 => {
			param1 => val,
			param2 => val,
			etc. },
	
		field2 => {
			param1 => val,
			param2 => val,
			etc. },

	},

	table2 => {
		fieldA => {
			param1 => val,
			param2 => val,
			etc. },

		fieldB => {
			param1 => val,
			param2 => val,
			etc. },
	},
};
		
The module containing $hash is loaded in startup.pl at boot.
I then have a package that creates an object based on a slice of the hash:

package FooBar;

use Config qw($hash);

sub new {
	my ($class, $table, $field) = @_;

	# bless hash slice instead of copying to {} and blessing
	my $self = bless $hash->{$table}->{$field}, $class;

	return $self;

}

followed by various read-only access methods.
__END__


My question is will this cause $hash (or the used parts) to come unshared
in mod_perl2? Does Perl mark the anonymous hash ($hash->{$table}->{$field})
as being blessed into FooBar thereby causing a copy-on-write?

I feel like I may have taken my shoe off and started loading bullets in the
gun :?

Thanks,

jrbiii



*****CONFIDENTIALITY NOTICE*****
This e-mail and any files or attachments may contain confidential and
privileged information.  If you have received this message in error, please
notify the sender at the above e-mail address and delete it and all copies
from your system.


sharing big global hash and objects
Barksdale, Ray 19:56 on 17 Feb 2005

Re: sharing big global hash and objects
Perrin Harkins 21:12 on 17 Feb 2005

RE: sharing big global hash and objects
Barksdale, Ray 21:51 on 17 Feb 2005

Generated at 11:21 on 20 Feb 2005 by mariachi v0.52