June 2005
Beginner
480 pages
10h 31m
English
When I discussed how to initialize a hash, I hinted that hashes and arrays are somehow related. Whenever a hash is used in a list context, Perl unwinds the hash back into a flat list of keys and values. This list can be assigned to arrays, like any other list:
%Movies = ( 'The Shining' => 'Kubrick', 'Ten Commandments' => 'DeMille', Goonies =>'Spielberg'); @Data = %Movies;
At this point, @Data is an array containing six elements. (The even elements—zero included—are directors' names, and the odd elements are movie titles.) You can perform any normal array operation on @Data, and then you can reassign the array to %Movies, as ...
Read now
Unlock full access