On Feb 20, Tushar Kulkarni said:

>%h = ( one => 15,
>        two => 26,
>        three => 37 );
>
>my @a;
>
>foreach (@a {keys %h}) { $_ = $_ + 10; }

Uh, why did you declare @a and then use %a here?  @a{...} is a HASH slice
of %a.  @a[...] is an ARRAY slice of @a.  Two different things.

What your code does is make a hash, %a, with the same keys as %h, and sets
the values for those keys to 10.

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


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

Reply via email to