The use of hashing in Perl

Source: Internet
Author: User
Tags hash

A summary of the use of Kazakhstan in Perl

To assign values to a hashing value pair with a fat arrow

%some_hash = (' jim ' => ', ' Tom ' => ', ' Jerry ' => ' 21 ');

Convert Hash to List

%any_hash = (K1, ' v1 ', K2, ' v2 ', K3, ' v3 ', K4, ' V4 ');
@arr =%any_hash;

The keys function that extracts the keys from the hash, for example, into an array @k

My @k = Keys%any_hash;

Values function that extracts the value of the hash, for example, into an array @v

My @v = values%any_hash;

Each function extracts the keys and values from the hash, such as the return key-value to $k, $v

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/extra/

while ($k, $v) = each%any_hash) {

Print "$k => $v \ n";
}

exists function, check to see if a key exists in the hash, return true if there is a false

if (exists $any _hash{k1}) {

Print "This key exists.\n";
}

Delete function, deleting the keys in the hash

Delete $any _hash{k2};

[Not finished]

This article is from the "Strive for" blog, please be sure to keep this source http://carllai.blog.51cto.com/1664997/1175028

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.