PERL Data Types and Objects
Perl has three data types:
- scalars – Scalars can hold elementary data, i.e., string, integer, float …
- arrays of scalars – Arrays of scalars in short arrays can hold arrays of scalar values.
- associative arrays of scalars. – Associative arrays of scalars are also called as hashes contain key, value pairs. There are like arrays only but the difference is these are indexed by strings where arrays are indexed by integers.
Declaration of scalar
Syntax : $var_name
Example: $name # holds string value
$num #holds numeric value
Note: no differentiation in declaring string or numeric variable.
Declaration of Arrays
Syntax : @arr_name
Example: @name #holds a list of scalar values
Declaration of Hashes
Syntax : %hash_name
Single element at index ‘i’ – $arr_name[i]
All elements at once – @arr_name
Single element at ‘key’ position – $hash_name(key)
All elements at once – %hash_name
If You need more visit our site – www.iguddy.com