Perl Topics





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
Perl Tutorial
Introduction Introduction
Installing Perl Installing Perl
Basics of Perl Basics of Perl
Scalar Variables Scalar Variables
Operators Operators
Control Structures Control Structures
Lists Lists
Array Array
Arrays Manipulation Arrays Manipulation
Arrays Functons Array Functions
Hash Hash
Hash Functions Hash Functions
String Functions String Functions
Regular Expression Regular Expression
Regular Expression Functions Regular Expression Functions
Numerical Functions Numerical Functions
List Functions List Functions
User Defined Function User Defined Function
File Handling File Handling
Forums Ask Your Doubts
Feedback Feedback
 





Hash Structure in Perl


Tutorials Perl

Topic

What is a Hash Structure?
Ways of Assigning variables to data structures?


Explanation

Hash is a special kind of Data Structure, which takes very less time to find whether the specified data exists.It is used usually with large volume of data, so its internal structures also complicated.

Every element of hash has a "key" which is a string used to uniquely identify an item in the hash. The assigning "value" can be any form of scalar data. Hash variables start with the symbol "%".

Assigning Variables to data structures:
Example:
    %name = ('Tom', 26, 'Peter', 51, 'Jones', 23);
    %name = ('Tom' => 26, 'Peter' => 51, 'Jones' => 23);
    %name = (Tom => 26, Peter => 51, Jones => 23);

In the above examples, key and value pairs are seperated by commas, but "=>" operator is equivalent to a comma, in the last example we have assigned strings without the the single quotes,even this works, the only issue is that usually perl expects a string before the "=>" operator, if used without single quotes we cannot embedd blank spaces.All the above statements are good enough to be used with perl.






A Note
Simple introduction, basic CGI perl programming codes with examples. Do send your feedback or suggestions on this tutorial. This is a copyright content.

Other Links

web hosting