how to grep perl Hash Keys in to an array? -
Iam need help in understanding a perl newbie and piece of code below.
I have a perl hash defined like this
1 my% myFavorite = ("Apple" => "Apple"); 2 my @ frits = ("apple", "orange", "grapes"); 3 @myFavourite {@fruits}; # How does it give Apple returns? It would be great if Pearl Master can tell what is happening in Line 3 of the code above. My favorite has been declared a hash, but used as an array? And the statement only takes the keys of the hash, puts it in the array and assumes a hash with the key that was searched. Is this the way that we repeat the hash key in Ashera?
This does not return the applet. It evaluates a hash slice that contains all the values in the hash that are related to the keys present in the $ MyFavorite {grape}) @foods . Note that if you turn on alerts that you get 2 warnings without initial values, that is because the myFavorite contains the key orange and grapes Values are not included for. By default, there is a shortcut for @myFavourite {@fruits} ($ myFavourite {Apple}, $ myFavourite {Orange}, and see 'hash slice' in copy. , which in this case is ($ myFavourite {Apple}, undef, undef) . If you print it, you can see only one output Apple .
Comments
Post a Comment