in reply to Not getting this assignment ...

You have to understand that a hash is an associative array, why associative? because each one of its indices (keys) is made to link to a value, the key is embraced within {} and the values can be assigned to a key in many different ways. Since a hash is a type of an array (arrays are essentially lists ) then list functions like reverse or sort can be performed on a hash (their behavior varies between arrays and hashes), however, a hash has its own set of functions as well, like each, keys,values. Read more about hashes at http://perldoc.perl.org/search.html?q=hash.

What's in a hash value?, a value can be as simple as a number or a string or a single scalar, or can progressively take an advanced shape, in that case the entire hash represents an advanced data structure.

If you have an array of 3 elements, you can access the second element directly by giving its position (index), this is called subscripting..

@array = (0,1,2); print $array[1]; ^
The same thing can be done to a hash, you want to access a given value, you give its position (key):
my %hash = (fruit=>banana, veg=>'cucumber'); print $hash{fruit}; ^
Why $ precedes a hash or an array when we're subscripting?, because in Perl, a single subscript is a single scalar so it makes sense that it is treated as such, perl gives you a warning in case you tried print @array[1]; and tells you that it is better written as print $array[1];

Data structures can be an amalgam of arrays, hashes, scalars so that one hash key can link to a value that is a hash of different keys and these different keys in the linked-to hash can themselves again be linking to an array for instance. The flexibility is that you can define the data structure yourself and build up on it.

Check the Tutorials for:

While this list is not exhaustive, you can refer to Reviews->Book Reviews and avail of the Super Search utility.. Another rich resource is the Perl Documentation, which you can also access from your terminal as well by typing %perldoc at your command prompt and from there you can learn how to make use of the documentation that is packaged with your version of Perl.

While I am just aiming to show you -in context to your question- the different types of resources that you can always refer to I have to include the Comprehensive Perl Archive Network (CPAN), this is a source of Perl modules, libraries and many other useful code.

Hang in there and have a nice Perl journey :) ...


Excellence is an Endeavor of Persistence. A Year-Old Monk :D .