Perl
  Home arrow Perl arrow Page 4 - Perl: Bon Voyage Lists and Hashes
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PERL

Perl: Bon Voyage Lists and Hashes
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 1
    2008-08-12


    Table of Contents:
  • Perl: Bon Voyage Lists and Hashes
  • Adding and Removing Values
  • Push
  • Making Hashes Out of Lists

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Perl: Bon Voyage Lists and Hashes - Making Hashes Out of Lists
    ( Page 4 of 4 )

    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:


    #!/usr/bin/perl

    %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:

    Conclusion

    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 Articles          >>> More By James Payne
     

       

    PERL ARTICLES

    - More Perl Bits
    - Perl, Bit by Bit
    - Basic Charting with Perl
    - Using Getopt::Long: More Command Line Option...
    - Command Line Options in Perl: Using Getopt::...
    - Web Access with LWP
    - More Templating Tools for Perl
    - Site Layout with Perl Templating Tools
    - Build a Perl RSS Aggregator with Templating ...
    - Looping, Security, and Templating Tools
    - Perl: Bon Voyage Lists and Hashes
    - Templating Tools
    - Perl: Number Crunching
    - Perl Debuggers in Detail
    - Debugging Perl





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    Stay green...Green IT