At 09:37 PM 6/28/01 -0400, twelveoaks wrote:
>Peter Scott Wrote:
>
> > my %h;
> > @h{@vars} = ();
> > if (keys %h != @vars) { $youlose = "yes"; }
>
>Maybe I'm missing something - won't these *always* match, since @vars has 
>been used to create keys %h?
>
>It seems that way when I test it.
>
>What I want to detect is whether any two of the values within @vars are 
>identical.
>
>Will this do that?

Observe, ye doubter:

$ perl -le '@vars = qw(one two three two); @h{@vars} - (); print
  "Duplicate in (@vars)" unless keys %h == @vars; @vars = qw(one two three 
four);
@hh{@vars} = (); print "Duplicate" unless keys %hh == @vars'
Duplicate in (one two three two)
$

Because.. what do we know about hash keys?  They must be... *prompt* *prompt*
--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com

Reply via email to