SPUG: MORE INFO: Array Naming Question

Yitzchak Scott-Thoennes sthoenna at efn.org
Wed Feb 4 12:55:33 CST 2004

On Wed, Feb 04, 2004 at 10:19:36AM -0700, "North, Walter" <wnorth at state.mt.us> wrote:
> I collect some data from a storage array and read it into a hash
> with the date as the key from which I then produce a graph for perusal
> by management.
> More storage arrays are on the way and I'd like to combine the data
> however I haven't been able to come up with how to create a hash
> with the storage array name as a hash that contains another hash
> of the data keyed by date.
> So I figured I could turn out multiple hashes with the date as
> a key.
> However I would prefer not to have to modify the script to add another
> hash each time we get another storage device.  Hence I would want
> to increment the name for example:
> ST_ARRAY_1 and the next would be ST_ARRAY_2 etc.
> A hash of hashes seems to be the superior method, but while I have
> done hashes of arrays I cannot seem to get a satisfactory hash of hashes.

To use a hash of hashes in place of your existing hash,
wherever you have $oldhash{$date} use $newhash{$storagearray}{$date}.
Where you have %oldhash, use %{$newhash{$storagearray}}.

Does that help?  You might read through perldoc perldsc.

More information about the spug-list mailing list