networktestinggenius.tk
Your networking tutor
Exclusive networking testing notes
Learn Networking & Testing topics

PERL Data types
Different types of Perl datatypes.
-
Scalars
-
Arrays (lists)
-
Associative arrays (hashes)
Scalars
Scalar variables are used to store single values - for example, a number or a string. They are preceded by the dollar sign ($). Here are some examples of scalars:
$name="Thiru";
$age = 26;
Arrays (lists)
Arrays, often called lists, can store a list of many scalar values at once. They are preceded by the at sign (@). Here are some arrays in Perl:
@names = ( "Thiru", "Bhuvana", "Selvi" );
@age = ( 26, 60, 18 );
print $names[0];
print $names[1];
Associative arrays (hashes)
The associative array, often called a hash. Associative arrays are similar to normal arrays, with one important difference. Instead of using numbers to index each element in an array, you can use more meaningful strings.
Hash variables are preceded by the percent sign (%).
Here are some examples of hashes:
colour_purple = ( r => 255, g => 0, b => 255 );
This index is often called a key, and the corresponding element is called a value.