--- Martin van-Eerde <[EMAIL PROTECTED]> wrote:
> could you walk me through @h{@vars} = ()
> I think it means many keys of the hash will be assigned an 
> undefined list.
> I dont understand the @ meaning array in @h !!
> > my %h;
> > @h{@vars} = ();
> > if (keys %h != @vars) { $youlose = "yes" }

The lexical symbols in Perl tend to tell the parser what sort of value
to expect when it's done parsing the line. That's probably a horrible
oversimplification, but it's good for this point.

In other words, when you look up a value in a two-dimentional array,
your final value is going to be a scalar, so you use a $ even though
you're referencing an array, like this: $array[$ndx1][$ndx2]

In the example above, %h is actually a hash, but an entire array of
keys are being set (with undef's) at once, so it's an array assignment
to the hash keys: @h{@vars} = ();

You could say 
    for (@vars) {
        $h{$_} = undef;
    }
to accomplish much the same thing, but doing it at once is much easier
once you understand what's going on.

Does that help?

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

Reply via email to