On May 28, 7:41 am, [EMAIL PROTECTED] (Jeevs) wrote: > On May 28, 11:35 am, [EMAIL PROTECTED] (Jeevs) wrote: > > > @hashi = @hash{qw (jeevan, sarika)}; > > print @hashi; > > > this gives me the values of keys jeevan and sarika.. how does this > > work ...
It works because that's the syntax for a hash slice--slices use the @ to signify multiples of things. > ok i got it ... > and > I think i was not clear in my query... > I was expecting an hash slice to be > %hash{qw(jeevan sarika)} which seems more logical as i said earlier... Perhaps so. Which is why ... > WEll i was browsing for more information and found out it has been > taken care of in perl6 :) Well, "taken care of" if you think it's broken--not everyone does. > where a new operator (qoute word) is introduced <> instead of qw() in > perl5. > u can write the above hash as > > @hashi = %hash<jeevan sarika>; > print @hashi; > > and u can get the same output as above... For the sake of discussion: my %hash = ( a => 1, b => 2, c => 3 ); print "%: ", %hash; print "keys: ", keys %hash; print "vals: ", values %hash; print "[EMAIL PROTECTED]: ", @hash{ qw( a b c ) }; print "[EMAIL PROTECTED]: ", @hash{ keys %hash }; print "[EMAIL PROTECTED]: ", @hash{ sort keys %hash }; __END__ %: c3a1b2 keys: cab vals: 312 @1: 123 @2: 312 @3: 123 Cheers, -- Brad -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/