On Wed, 1 Feb 2006, Angus wrote:

> 
> I am trying to write a little script that will compare two hashes with the
> same keys but conflicting values.  I have found some great examples of how
> to compare hashes and locate common keys or missing keys (in the cookbook).
> I have also found a great example of how to locate duplicate keys in two
> hashes (also in the cookbook) but nothing that helps with this question in
> particular.  The following example is based on a pair of hashes using
> hostname and ip address information.
> 
> #!/usr/bin/perl
> 
> my %actual = (
> 
> My @common = ();  # it seems with this I at least have an array that now
> 
> Foreach my $host (keys %actual) {
> 
>             Push (@common, $host) if exists $register{$host);
> 
> My @not_common = ();
> 
> Foreach my $host (values %actual) {
> 
>             Push(@not_common, $host) unless $register{$host} == $host; }
> 
> Print "@not_common\n";
> 
> My @match = ();
> 
> If ($actual{$host1} == $register{$host1}) {
> 
>             Print "They match!\n";}
> 
> Else {
> 
>             Print "no match. \n";}




I am a bit too tired to look at this, but wonder what sort of system
allows you to use My, Else, Print etc?



Owen


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


Reply via email to