From: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> Hi
> I have  a script which contains 2 hashes of file names as the keys and
> md5 sums as the values. I am looking for ideas on fast and efficient
> ways to compare the 2 hashes in the manner of the pseudo code below
> 
> --
> %base_hash
> %new_hash
> 
> for keys in %new_hash
>   if key in %new_hash exists in %base_hash
>       compare  values and do something
>   else
>       do something else
> --

Let's convert this to Perl:

for my $key (keys %new_hash) {
 if (exists $base_hash{$key}) {
  if ($new_hash{$key} > $base_hash{$key} {
   do_something($key);
  }
 } else {
  do_something_else($key);
 }
}

Looks quite close to you pseudocode to me.

Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to