Pages

Showing posts with label array. Show all posts
Showing posts with label array. Show all posts

Thursday, August 8, 2013

Multi-Dimensional Hashes in Perl


Introduction To Hashes

Perl hashes are data types that allow you to associate data to a key. For example, a hash can store article titles with the date of publication as the key:

%hash = (20030227 => 'Multi-dimensional hashes',
         20030113 => 'Introduction to mod_perl',
         20021201 => 'The CPAN Module'
);

This is a one-dimensional hash.

Wednesday, August 7, 2013

Multi-Dimensional Arrays in Perl


Introduction to Arrays

A Perl array is a data type that allows you to store a list of items. You create them by assigning them to an array variable. The array variable is identified by a @ prefix. To define a list of dates, we do this:

@array = ('20020701', '20020601', '20020501');
This is a one-dimensional array.