.------[ Ned Cunningham wrote (2002/10/16 at 11:38:07) ]------
 | 
 |  How would you write to those 2 hashes???
 |  

    I'm not quite sure what you mean by this. You can update the value
    at a certain key at anytime by simply assigning something to it like

    $hash1{2} = 'foobar'; 

    This sets hash1's value at key '2' to 'foobar'. 

    Or am I misunderstanding your question? 

 ---------------------------------
   Frank Wiles <[EMAIL PROTECTED]>
   http://frank.wiles.org
 ---------------------------------

 |  Subject:    Re: comparing two hashes
 |  
 |  .------[ Egleton, Gary wrote (2002/10/16 at 14:54:57)
 |  | 
 |  |  Hi,
 |  |  
 |  |  can any one point me at how to compare two hases.
 |  |  
 |  |  ie
 |  |  
 |  |  hash1
 |  |   1 abc
 |  |   2 def
 |  |   3 ghi
 |  |  
 |  |  hash2
 |  |   1 abc
 |  |   2 defzzz
 |  |   3 ghi
 |  |  
 |  |  I want to take the values for matching keys and see if
 |  they are the same if
 |  |  not write out the value
 |  |  
 |  |  so in the above the values in 1 and 1 are ok, the values
 |  in 3 and 3 are ok
 |  |  but in key 2 they do not match
 |  |  
 |  `-------------------------------------------------
 | 
 |  This should do it: 
 |
 |  foreach my $key ( keys(%hash1) ) { 
 |  
 |      if( $hash1{$key} ne $hash2{$key} ) { 
 |          print "hash1: $hash1{$key} hash2: $hash2{$key}\n"; 
 |      }
 |  
 |  }
 |  
 `-------------------------------------------------



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to