Perl slices (arrays and hashes) two

Source: Internet
Author: User
Slicing usage can extract values from arrays and hashes
my @array = qw (aa bb cc dd); my @select = @array [1,3]; print "@select \ n"; ## output bb dd123456
Value in hash
my% hash = ("a" => 1, "b" => 2, "c" => 3, "d" => 4,); my @select = @hash {qw (ac)}; ## Extract the value corresponding to key 'a''c' print "@select \ n"; ## Output is 1 31234567891011
Hash-of-hash
my% hash = ("a" => 1, "b" => 2, "c" => 3, "d" => 4,); my% select =% hash {qw (ac)}; ## Extract the hashmap with key 'a''c' {print "$ _ => $ select {$ _} \ n"} keys% select; ## The output is: a => 1c => 3


perl slicing (array and hash) two
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.