RSS Subscription
Linux Howtos & Tutorials

Enter your email:

Delivered by


NOTE:New tutorials are from LinuxCareer.com

Poll

Do you own or wish to have iPhone?
 


Linux eBooks FREE Download
A guide to programming Linux kernel modules
Introduction to Linux - A Hands on Guide
A Newbie's Getting Started Guide to Linux

Linux from Scratch - Create Your Own Linux System - Free eBook

Linux: The Hacking Solution (v.3.0)

SQLite 3 with PHP Essential Training – Free Video Training Tutorials

This guide will introduce you to the world of GNU/Linux

The GNU/Linux Advanced Administration

A Complete Beginner's Manual for Ubuntu 10.04 (Lucid Lynx)

Advanced Bash-Scripting Guide

Set up, maintain, and secure a small office email server

Partner Linux Sites:
How-To.LinuxCareer.com
Jobs.LinuxCareer.com
TuxMachines
Monsterb
LinuxBloggers
AdamsInfo
LinuxScrew
All For Linux

Perl hash

Article Index
1. Creating perl hash
2. Print all perl hash values

Perl Hash Let's see on couple examples how we can use perl hash. First we need to know that perl hash value is accessible via key. Therefore:

$myhashvalue = $hash($key)

1. Creating perl hash

#!/usr/bin/perl
$perl_hash{one} = Using;
$perl_hash{two} = perl;
$perl_hash{three} = hash;

print $perl_hash{three} . "\n";

First we have create a $perl_hash to hold three values "Using perl hash" to be accessible via three keys"one two three", respectively. Then we user print to print a hash value using key "three". Use join to print all hash key/value pairs:

#!/usr/bin/perl
$perl_hash{one} = Using;
$perl_hash{two} = perl;
$perl_hash{three} = hash;

print join(" ", %perl_hash) . "\n";

2. Print all perl hash values

#!/usr/bin/perl
$perl_hash{one} = Using;
$perl_hash{two} = perl;
$perl_hash{three} = hash;

while(($key, $value) = each(%perl_hash)) {
	print "$value\n";
}

Share this linux post:

Submit Perl hash in Delicious Submit Perl hash in Digg Submit Perl hash in FaceBook Submit Perl hash in Google Bookmarks Submit Perl hash in Stumbleupon Submit Perl hash in Technorati Submit Perl hash in Twitter
 
Comments for this page are closed !!!
Please visit our new Linux Forum for additional help or discussion.


Linux eBooks FREE Download