> I want to test if anything was changed in %master.
If you are writing the code, the simplest thing is to flag that a change is
made when you make the change. You could also use tie(), as was mentioned,
to do this task transparently without having to alter your calculation code.
You could also store the item as text easily (in two dimensions):
$as_text = join( "\n\n",
map {
join( "\n",
map { join( '', @$_ ) } @{$master{$_}}
)
} sort keys %master );
-K
"Do not meddle in the affairs of dragons, because you are crunchy and taste
good with ketchup."
> From: Adam Stern <[EMAIL PROTECTED]>
> Date: Tue, 13 Mar 2001 23:37:31 -0500 (EST)
> To: [EMAIL PROTECTED]
> Subject: Re: [MacPerl] List of Lists into Hash Array
>
> Hi!
>
> Thanks for all your help. It was really really useful.
>
> I'm almost done with the program I'm writing, but I ran into one
> complication:
>
> I have this hash array with list of list references:
> an example of the variable type I'm dealing with:
> $master{key} = [ ["a","b","c"], ["d","e","f"], ["g","h","i"] ];
> to access element 1,2: $master{key}->[1][2] # that is "f"
>
> Here is the problem:
> my program takes in the %master hash array, changes the info inside, and
> prints all the matricies.
> I want to test if anything was changed in %master.
>
> I don't think I can do a straight forward copy %store = %master. Why?
> Because I'm using references to arrays, not actual arrays. So the values
> in %store point to the same things as %master. If %master changes, so
> does %store.
>
> But, then again, when I try the %store = %master thing in my program:
>
> for (1..$times) {
> %orig = %master; # master changes each time the
> # for loop is executed (sometimes)
> print "processing time number $_\n";
> process();
> %new = %master;
> if (%new != %orig) { print "***changed\n"; }
> }
>
> It never says "***changed", I think because I am using refs.
>
>
> Any ideas?
>
>
> Thanks.
>
> - Adam Stern
>
>