Home arrow Perl Programming arrow Page 4 - Perl: Bon Voyage Lists and Hashes

Making Hashes Out of Lists - Perl

Thanks for stopping by for our final article on Perl lists and hashes. This marks our twelfth issue on the subject (at least until we get to some more advanced techniques later on) and in it, we will look at a few of the functions for manipulating two-dimensional lists, how to create lists with more than two dimensions, and finally, how to make a hash full of lists, which is really quite a handy tool.

  1. Perl: Bon Voyage Lists and Hashes
  2. Adding and Removing Values
  3. Push
  4. Making Hashes Out of Lists
By: James Payne
Rating: starstarstarstarstar / 1
August 12, 2008

print this article



You can create hashes that contain list values pretty easily in Perl. This allows you to find list items using a key, as showcased in earlier tutorials. Here we will store some list values in our hash %Hawtie:


%Hawtie =(

'10' => ['Angelina Jolie', 'Actress', 'My Baby Mama'],

'1' => ['Valerie Bertonelli', 'Professional Boxer', 'I would have to

be pretty drunk']


$Hawt = $Hawtie{'10'}[0];

print $Hawt . "\n\n";

$Not = $Hawtie{'1'}[0];

print $Not;

Above we created the hash %Hawtie and stored two list values in it, the first containing our 10, Angelina Jolie and the second containing our 1, Valerie BertandErnie. We then stored each value in a hot ($Hawt) variable or a not ($Not) variable and printed each out.

Here is what we got:


Well that is all the time we have left for this article, and for the time being, it wraps up our discussion of lists and hashes. In our next series we will be looking more in-depth at Conditionals and Loops and learning to use them in a more advanced way.

Till then...

>>> More Perl Programming Articles          >>> More By James Payne

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Perl Turns 25
- Lists and Arguments in Perl
- Variables and Arguments in Perl
- Understanding Scope and Packages in Perl
- Arguments and Return Values in Perl
- Invoking Perl Subroutines and Functions
- Subroutines and Functions in Perl
- Perl Basics: Writing and Debugging Programs
- Structure and Statements in Perl
- First Steps in Perl
- Completing Regular Expression Basics
- Modifiers, Boundaries, and Regular Expressio...
- Quantifiers and Other Regular Expression Bas...
- Parsing and Regular Expression Basics
- Hash Functions

Developer Shed Affiliates


Dev Shed Tutorial Topics: