perltutorial
planetscape
hash
tutorial
Data::Dumper
data_structure
reference
FakeHash
<font size=-2>
<p>last updated: <a href="#updates">2008-12-11</a></p>
</font>
<small>
<p align="center"><font color="#0080ff">N</font>
<font color="#0084fa">o</font>
<font color="#0089f5">t</font>
<font color="#008ef0"> </font>
<font color="#0092ec">E</font>
<font color="#0097e7">x</font> <font color="#009ce2">a</font>
<font color="#00a0de">c</font> <font color="#00a5d9">t</font>
<font color="#00aad4">l</font>
<font color="#00afcf">y</font>
<font color="#00b3cb"> </font> <font color="#00b8c6">a</font>
<font color="#00bdc1"> </font>
<font color="#00c1bd">H</font>
<font color="#00c6b8">a</font>
<font color="#00cbb3">s</font> <font color="#00cfaf">h</font>
<font color="#00d4aa"> </font>
<font color="#00d9a5">T</font>
<font color="#00dea0">u</font>
<font color="#00e29c">t</font>
<font color="#00e797">o</font>
<font color="#00ec92">r</font>
<font color="#00f08e">i</font>
<font color="#00f589">a</font>
<font color="#00fa84">l</font>
</p>
</small>
<p><strong>Quick links:</strong></p>
<p>
<a href="#code">Code Illustrating Hashes and Related Syntax</a><br />
<blockquote>
<br /><a href="#assignment">Hash Assignment</a>
<br /><a href="#access">Hash Element Access</a>
<br /><a href="#exists">exists ( $hash{$key} )</a>
<br /><a href="#keys">keys( %hash )</a>
<br /><a href="#delete">delete ( $hash{key} )</a>
<br /><a href="#values">values( %hash )</a>
<br /><a href="#each">each( %hash )</a>
<br /><a href="#inverse">Make an "Inverse" Hash</a>
<br /><a href="#expand">Let's Expand Our Real-World Example...</a>
</blockquote>
<a href="#fakehash">Visualizing a Hash Structure with FakeHash</a><br />
<a href="#resources">A List of Hash Resources</a><br />
<a href="#updates">Updates</a><br />
</p>
<hr />
<a name="code">
<h4>Some Very Simple Code Illustrating Hashes and Related Syntax</h4>
</a>
<readmore><code>
#! /usr/local/bin/perl -w
# myHash.pl
# these are very simplistic syntax examples;
# there's much more to know, so see the
# resources below!
use strict;
use warnings;
use Data::Dumper;
</code>
<a name="assignment"></a>
<code>
# Hash Assignment
# In this case, a
# 1 : 1 relationship
# key => value
my %StateName = (
AK => 'Alaska',
AL => 'Alabama',
AR => 'Arkansas',
AZ => 'Arizona',
CA => 'California',
CO => 'Colorado',
CT => 'Connecticut',
DC => 'District Of Columbia',
DE => 'Delaware',
FL => 'Florida',
GA => 'Georgia',
HI => 'Hawaii',
IA => 'Iowa',
ID => 'Idaho',
IL => 'Illinois',
IN => 'Indiana',
KS => 'Kansas',
KY => 'Kentucky',
LA => 'Louisiana',
MA => 'Massachusetts',
MD => 'Maryland',
ME => 'Maine',
MI => 'Michigan',
MN => 'Minnesota',
MO => 'Missouri',
MS => 'Mississippi',
MT => 'Montana',
NC => 'North Carolina',
ND => 'North Dakota',
NE => 'Nebraska',
NH => 'New Hampshire',
NJ => 'New Jersey',
NM => 'New Mexico',
NV => 'Nevada',
NY => 'New York',
OH => 'Ohio',
OK => 'Oklahoma',
OR => 'Oregon',
PA => 'Pennsylvania',
RI => 'Rhode Island',
SC => 'South Carolina',
SD => 'South Dakota',
TN => 'Tennessee',
TX => 'Texas',
UT => 'Utah',
VA => 'Virginia',
VT => 'Vermont',
WA => 'Washington',
WI => 'Wisconsin',
WV => 'West Virginia',
WY => 'Wyoming'
);
my $href = \%StateName; # reference to the hash %StateName
print Dumper $href; # note the order will differ from that above
print "\n";
</code>
<a name="access"></a>
<code>
# hash element access
my $State = 'SD'; # planetscape's home state
my $Name = $StateName{$State};
print "planetscape lives in " . $Name . "\.\n\n";
</code>
<a name="exists"></a>
<code>
# exists ( $hash{$key} )
$State = 'QC'; # Quebec, Canada
if (exists($StateName{$State})) {
print "The abbreviation for $State is " . $StateName{$State} . "\.\n\n";
} else {
print $State . " is not a state! (yet)\n\n";
}
</code>
<a name="keys"></a>
<code>
# keys( %hash )
my $count = keys %StateName;
print "There are $count elements in the hash.\n\n";
foreach $State (keys(%StateName)) {
print "State abbreviation is '$State'\n";
}
print "\n";
</code>
<a name="delete"></a>
<code>
# delete ( $hash{key} )
delete($StateName{DC}); # DC is not actually a state,
# it's a postal abbreviation
</code>
<a name="values"></a>
<code>
# values( %hash )
$count = values %StateName; # $count is one less since we deleted DC
print "There are $count elements in the hash.\n\n";
foreach $State (values(%StateName)) {
print "State name is '$State'\n";
}
print "\n";
</code>
<a name="each"></a>
<code>
# each( %hash )
while (my($key,$value)=each(%StateName)) { # there's lots more to know
print "key='$key', value='$value'\n"; # about "each" - see the
# resources below!
}
print "\n";
</code>
<a name="inverse"></a>
<code>
# make an inverse hash
my %StateAbbreviation = reverse %StateName;
# exists ( $hash{$key} )
$State = 'Quebec'; # QC
if (exists($StateAbbreviation{$State})) {
print "The abbreviation for $State is " . $StateAbbreviation{$State} . "\.\n\n";
} else {
print $State . " is not a state! (yet)\n\n";
}
print "\n";
</code>
<a name="expand"></a>
<code>
# let's expand our real-world example from a hash of States
# to a hash of postal abbreviations (not exhaustive)
my %PostalCode = %StateName; # copy %StateName to %PostalCode
$PostalCode{AS} = 'American Samoa';
$PostalCode{DC} = 'District of Columbia';
$PostalCode{FM} = 'Federated States of Micronesia';
$PostalCode{GU} = 'Guam';
$PostalCode{MH} = 'Marshall Islands';
$PostalCode{MP} = 'Northern Mariana Islands';
$PostalCode{PW} = 'Palau';
$PostalCode{PR} = 'Puerto Rico';
$PostalCode{VI} = 'Virgin Islands';
$PostalCode{PW} = 'Palau';
# many more postal codes and abbreviations for the US and Canada
# may be found here: http://www.usps.com/ncsc/lookups/usps_abbreviations.html
# and here: http://canadaonline.about.com/library/bl/blpabb.htm
foreach my $pc (keys(%PostalCode)) {
print "PostalCode for '$PostalCode{$pc}' is '$pc'\n";
}
</code></readmore>
<hr />
<a name="fakehash">
<h4>Visualizing a Hash Structure with FakeHash</h4>
</a>
<p>[cpan://FakeHash|FakeHash] is a module by Mark-Jason [Dominus] which was
first announced [id://47536|here]. I have elaborated slightly on the
[id://47536|code presented] in order to demonstrate some additional details such
as setting drawing parameters. (More info on [cpan://FakeHash|FakeHash] can be
found [http://perl.plover.com/FakeHash/FakeHash.pm|here].)</p>
<p> </p>
<code>
use strict;
use warnings;
use FakeHash;
my %h = (
When => 1,
in => 2,
the => 3,
course => 4,
of => 5,
human => 6,
events => 7,
it => 8,
becomes => 9,
necessary => 10,
for => 11,
one => 12,
people => 13,
);
open( my $FILEHANDLE, ">FakeHashDrawing.txt" );
my $fake = FakeHash::DrawHash->new;
$fake->draw_param( 'BUCKET', [1.5, 0.75] );
$fake->draw_param( 'KVP' => [2.0, 0.75] );
while ( my ( $key, $value ) = each(%h) ) {
$fake->store( $key, $value );
}
$fake->draw($FILEHANDLE);
close $FILEHANDLE;
</code>
<p>This code produces the following output:</p>
<readmore>
<code>
.PS
boxwid:=1.5; boxht:=0.75
B00: box
boxwid:=1.5; boxht:=0.75
B01: box with .n at B00.s
circle at B01.c rad 0.1 filled
arrow from B01.c right boxwid/2 + 0.2
boxwid:=2; boxht:=0.75
N0100: box "becomes" "9" "134720492145(17)"
boxwid:=1.5; boxht:=0.75
B02: box with .n at B01.s
circle at B02.c rad 0.1 filled
arrow from B02.c right boxwid/2 + 0.2
boxwid:=2; boxht:=0.75
N0200: box "necessary" "10" "164114526854434(2)"
boxwid:=1.5; boxht:=0.75
B03: box with .n at B02.s
circle at B03.c rad 0.1 filled
arrow from B03.c right boxwid/2 + 0.2
boxwid:=2; boxht:=0.75
N0300: box "human" "6" "131651875(3)"
boxwid:=1.5; boxht:=0.75
B04: box with .n at B03.s
boxwid:=1.5; boxht:=0.75
B05: box with .n at B04.s
boxwid:=1.5; boxht:=0.75
B06: box with .n at B05.s
circle at B06.c rad 0.1 filled
arrow from B06.c right boxwid/2 + 0.2
boxwid:=2; boxht:=0.75
N0600: box "in" "2" "3686(6)"
boxwid:=2; boxht:=0.75
N0601: box "people" "13" "4647902198(22)"
boxwid:=2; boxht:=0.75
N0602: box "course" "4" "4135697990(6)"
boxwid:=1.5; boxht:=0.75
B07: box with .n at B06.s
boxwid:=1.5; boxht:=0.75
B08: box with .n at B07.s
circle at B08.c rad 0.1 filled
arrow from B08.c right boxwid/2 + 0.2
boxwid:=2; boxht:=0.75
N0800: box "When" "1" "3344568(24)"
boxwid:=2; boxht:=0.75
N0801: box "one" "12" "128504(24)"
boxwid:=1.5; boxht:=0.75
B09: box with .n at B08.s
circle at B09.c rad 0.1 filled
arrow from B09.c right boxwid/2 + 0.2
boxwid:=2; boxht:=0.75
N0900: box "events" "7" "4224378201(25)"
boxwid:=1.5; boxht:=0.75
B10: box with .n at B09.s
circle at B10.c rad 0.1 filled
arrow from B10.c right boxwid/2 + 0.2
boxwid:=2; boxht:=0.75
N1000: box "of" "5" "3882(10)"
boxwid:=1.5; boxht:=0.75
B11: box with .n at B10.s
circle at B11.c rad 0.1 filled
arrow from B11.c right boxwid/2 + 0.2
boxwid:=2; boxht:=0.75
N1100: box "the" "3" "133915(27)"
boxwid:=1.5; boxht:=0.75
B12: box with .n at B11.s
circle at B12.c rad 0.1 filled
arrow from B12.c right boxwid/2 + 0.2
boxwid:=2; boxht:=0.75
N1200: box "it" "8" "3692(12)"
boxwid:=2; boxht:=0.75
N1201: box "for" "11" "118444(12)"
boxwid:=1.5; boxht:=0.75
B13: box with .n at B12.s
boxwid:=1.5; boxht:=0.75
B14: box with .n at B13.s
boxwid:=1.5; boxht:=0.75
B15: box with .n at B14.s
.PE
</code>
</readmore>
<p>Once you have generated <code>FakeHashDrawing.txt</code> with the above Perl
code, you can convert it to PostScript with the following (under
[http://www.cygwin.com/|Cygwin]/*nix):</p>
<code>pic FakeHashDrawing.txt | groff -c -Tps > FakeHashDrawing.ps</code>
<p><a href="http://planetscape.perlmonk.org/FakeHash.png">View the Output</a></p>
<p>(I then used [http://www.jasc.com/products/paintshoppro/|Jasc Paint Shop Pro
8] to convert PostScript to [wp://PNG] for display purposes.)</p>
<p>If you prefer a more "modern" standard such as [wp://SVG], you can use a
utility such as [http://www.gnu.org/software/plotutils/plotutils.html|plotutils]'
<code>pic2plot</code> to convert from Unix <code>pic</code> format to [wp://SVG]
or any other of a wide variety of formats. For example:</p>
<code>pic2plot -T svg FakeHashDrawing.txt > FakeHashDrawing.svg</code>
<p>Produces (on [http://www.cygwin.com/|Cygwin]):</p>
<readmore>
<code>
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000303 Stylable//EN"
"http://www.w3.org/TR/2000/03/WD-SVG-20000303/DTD/svg-20000303-stylable.dtd">
<svg width="8in" height="8in" viewBox="0 0 1 1" preserveAspectRatio="none">
<title>SVG drawing</title>
<desc>This was produced by version 4.1 of GNU libplot, a free library for exporting 2-D vector graphics.</desc>
<rect x="0" y="0" width="1" height="1" style="stroke:none;fill:white;"/>
<g transform="translate(0.058854,-0.14453) scale(1,-1) scale(0.11458) " xml:space="preserve" style="stroke:black;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10.433;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;fill:none;fill-rule:even-odd;fill-opacity:1;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size-adjust:none;letter-spacing:normal;word-spacing:normal;text-anchor:start;">
<rect x="0" y="-0.375" width="1.5" height="0.75" style="stroke-width:0.010267;"/>
<rect x="0" y="-1.125" width="1.5" height="0.75" style="stroke-width:0.010267;"/>
<circle cx="0.75" cy="-0.75" r="0.1" style="stroke-width:0.010267;fill:gray;"/>
<line x1="0.75" y1="-0.75" x2="1.7" y2="-0.75" style="stroke-width:0.010267;"/>
<polygon points="1.6,-0.725 1.7,-0.75 1.6,-0.775 " style="stroke-width:0.010267;fill:black;"/>
<rect x="1.7" y="-1.125" width="2" height="0.75" style="stroke-width:0.010267;"/>
<text transform="translate(2.7,-0.56818) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">becomes</text>
<text transform="translate(2.7,-0.75) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">9</text>
<text transform="translate(2.7,-0.93182) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">134720492145(17)</text>
<rect x="0" y="-1.875" width="1.5" height="0.75" style="stroke-width:0.010267;"/>
<circle cx="0.75" cy="-1.5" r="0.1" style="stroke-width:0.010267;fill:gray;"/>
<line x1="0.75" y1="-1.5" x2="1.7" y2="-1.5" style="stroke-width:0.010267;"/>
<polygon points="1.6,-1.475 1.7,-1.5 1.6,-1.525 " style="stroke-width:0.010267;fill:black;"/>
<rect x="1.7" y="-1.875" width="2" height="0.75" style="stroke-width:0.010267;"/>
<text transform="translate(2.7,-1.3182) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">necessary</text>
<text transform="translate(2.7,-1.5) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">10</text>
<text transform="translate(2.7,-1.6818) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">164114526854434(2)</text>
<rect x="0" y="-2.625" width="1.5" height="0.75" style="stroke-width:0.010267;"/>
<circle cx="0.75" cy="-2.25" r="0.1" style="stroke-width:0.010267;fill:gray;"/>
<line x1="0.75" y1="-2.25" x2="1.7" y2="-2.25" style="stroke-width:0.010267;"/>
<polygon points="1.6,-2.225 1.7,-2.25 1.6,-2.275 " style="stroke-width:0.010267;fill:black;"/>
<rect x="1.7" y="-2.625" width="2" height="0.75" style="stroke-width:0.010267;"/>
<text transform="translate(2.7,-2.0682) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">human</text>
<text transform="translate(2.7,-2.25) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">6</text>
<text transform="translate(2.7,-2.4318) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">131651875(3)</text>
<rect x="0" y="-3.375" width="1.5" height="0.75" style="stroke-width:0.010267;"/>
<rect x="0" y="-4.125" width="1.5" height="0.75" style="stroke-width:0.010267;"/>
<rect x="0" y="-4.875" width="1.5" height="0.75" style="stroke-width:0.010267;"/>
<circle cx="0.75" cy="-4.5" r="0.1" style="stroke-width:0.010267;fill:gray;"/>
<line x1="0.75" y1="-4.5" x2="1.7" y2="-4.5" style="stroke-width:0.010267;"/>
<polygon points="1.6,-4.475 1.7,-4.5 1.6,-4.525 " style="stroke-width:0.010267;fill:black;"/>
<rect x="1.7" y="-4.875" width="2" height="0.75" style="stroke-width:0.010267;"/>
<text transform="translate(2.7,-4.3182) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">in</text>
<text transform="translate(2.7,-4.5) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">2</text>
<text transform="translate(2.7,-4.6818) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">3686(6)</text>
<rect x="3.7" y="-4.875" width="2" height="0.75" style="stroke-width:0.010267;"/>
<text transform="translate(4.7,-4.3182) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">people</text>
<text transform="translate(4.7,-4.5) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">13</text>
<text transform="translate(4.7,-4.6818) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">4647902198(22)</text>
<rect x="5.7" y="-4.875" width="2" height="0.75" style="stroke-width:0.010267;"/>
<text transform="translate(6.7,-4.3182) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">course</text>
<text transform="translate(6.7,-4.5) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">4</text>
<text transform="translate(6.7,-4.6818) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">4135697990(6)</text>
<rect x="0" y="-5.625" width="1.5" height="0.75" style="stroke-width:0.010267;"/>
<rect x="0" y="-6.375" width="1.5" height="0.75" style="stroke-width:0.010267;"/>
<circle cx="0.75" cy="-6" r="0.1" style="stroke-width:0.010267;fill:gray;"/>
<line x1="0.75" y1="-6" x2="1.7" y2="-6" style="stroke-width:0.010267;"/>
<polygon points="1.6,-5.975 1.7,-6 1.6,-6.025 " style="stroke-width:0.010267;fill:black;"/>
<rect x="1.7" y="-6.375" width="2" height="0.75" style="stroke-width:0.010267;"/>
<text transform="translate(2.7,-5.8182) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">When</text>
<text transform="translate(2.7,-6) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">1</text>
<text transform="translate(2.7,-6.1818) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">3344568(24)</text>
<rect x="3.7" y="-6.375" width="2" height="0.75" style="stroke-width:0.010267;"/>
<text transform="translate(4.7,-5.8182) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">one</text>
<text transform="translate(4.7,-6) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">12</text>
<text transform="translate(4.7,-6.1818) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">128504(24)</text>
<rect x="0" y="-7.125" width="1.5" height="0.75" style="stroke-width:0.010267;"/>
<circle cx="0.75" cy="-6.75" r="0.1" style="stroke-width:0.010267;fill:gray;"/>
<line x1="0.75" y1="-6.75" x2="1.7" y2="-6.75" style="stroke-width:0.010267;"/>
<polygon points="1.6,-6.725 1.7,-6.75 1.6,-6.775 " style="stroke-width:0.010267;fill:black;"/>
<rect x="1.7" y="-7.125" width="2" height="0.75" style="stroke-width:0.010267;"/>
<text transform="translate(2.7,-6.5682) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">events</text>
<text transform="translate(2.7,-6.75) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">7</text>
<text transform="translate(2.7,-6.9318) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">4224378201(25)</text>
<rect x="0" y="-7.875" width="1.5" height="0.75" style="stroke-width:0.010267;"/>
<circle cx="0.75" cy="-7.5" r="0.1" style="stroke-width:0.010267;fill:gray;"/>
<line x1="0.75" y1="-7.5" x2="1.7" y2="-7.5" style="stroke-width:0.010267;"/>
<polygon points="1.6,-7.475 1.7,-7.5 1.6,-7.525 " style="stroke-width:0.010267;fill:black;"/>
<rect x="1.7" y="-7.875" width="2" height="0.75" style="stroke-width:0.010267;"/>
<text transform="translate(2.7,-7.3182) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">of</text>
<text transform="translate(2.7,-7.5) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">5</text>
<text transform="translate(2.7,-7.6818) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">3882(10)</text>
<rect x="0" y="-8.625" width="1.5" height="0.75" style="stroke-width:0.010267;"/>
<circle cx="0.75" cy="-8.25" r="0.1" style="stroke-width:0.010267;fill:gray;"/>
<line x1="0.75" y1="-8.25" x2="1.7" y2="-8.25" style="stroke-width:0.010267;"/>
<polygon points="1.6,-8.225 1.7,-8.25 1.6,-8.275 " style="stroke-width:0.010267;fill:black;"/>
<rect x="1.7" y="-8.625" width="2" height="0.75" style="stroke-width:0.010267;"/>
<text transform="translate(2.7,-8.0682) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">the</text>
<text transform="translate(2.7,-8.25) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">3</text>
<text transform="translate(2.7,-8.4318) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">133915(27)</text>
<rect x="0" y="-9.375" width="1.5" height="0.75" style="stroke-width:0.010267;"/>
<circle cx="0.75" cy="-9" r="0.1" style="stroke-width:0.010267;fill:gray;"/>
<line x1="0.75" y1="-9" x2="1.7" y2="-9" style="stroke-width:0.010267;"/>
<polygon points="1.6,-8.975 1.7,-9 1.6,-9.025 " style="stroke-width:0.010267;fill:black;"/>
<rect x="1.7" y="-9.375" width="2" height="0.75" style="stroke-width:0.010267;"/>
<text transform="translate(2.7,-8.8182) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">it</text>
<text transform="translate(2.7,-9) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">8</text>
<text transform="translate(2.7,-9.1818) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">3692(12)</text>
<rect x="3.7" y="-9.375" width="2" height="0.75" style="stroke-width:0.010267;"/>
<text transform="translate(4.7,-8.8182) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">for</text>
<text transform="translate(4.7,-9) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">11</text>
<text transform="translate(4.7,-9.1818) scale(1,-1) " style="font-family:'Helvetica',sans-serif;font-size:0.15152;text-anchor:middle;baseline-identifier:centerline;stroke:none;fill:black;">118444(12)</text>
<rect x="0" y="-10.125" width="1.5" height="0.75" style="stroke-width:0.010267;"/>
<rect x="0" y="-10.875" width="1.5" height="0.75" style="stroke-width:0.010267;"/>
<rect x="0" y="-11.625" width="1.5" height="0.75" style="stroke-width:0.010267;"/>
</g>
</svg>
</code>
</readmore>
<p><i><b>For more on visualizing complex data structures, please see [id://481746]</b></i></p>
<hr />
<a name="resources">
<h4>A List of Hash Resources</h4>
</a>
<h5>Online:</h5>
<blockquote>
<h6>offsite:</h6>
<blockquote>
<p><a href="http://learn.perl.org/library/beginning_perl/3145_Chap03.pdf">
Chapter 3</a> in <a href="http://learn.perl.org/library/beginning_perl/">
<i>Beginning Perl</i></a> by Simon Cozens (<a href="http://www.adobe.com/products/acrobat/readstep2.html/">PDF</a>)</p>
<p>Chapter 5 of <a href="http://ebb.org/PickingUpPerl/pickingUpPerl.pdf"><i>
Picking Up Perl</i></a> by <a href="http://www.ebb.org/bkuhn">Bradley M. Kuhn</a>
(<a href="http://www.adobe.com/products/acrobat/readstep2.html/">PDF</a>)</p>
<p>Section 2.3 in <i><a href="http://www.greglondon.com/iperl/pdf/iperl.pdf">
Impatient Perl</a> </i>by
<a href="http://www.greglondon.com/">Greg London</a> (<a href="http://www.adobe.com/products/acrobat/readstep2.html/">PDF</a>)</p>
<p><a href="http://www.steve.gb.com/perl/tutorial.html">Steve's place - Perl
Tutorial</a>, by Steve Cook (<a href="http://www.steve.gb.com/perl/downloads/tutorial.tar.gz">archive</a>)</p>
<blockquote>
<ul>
<li>Lesson 2: <a href="http://www.steve.gb.com/perl/lesson02.html">No-one
likes being type cast</a> </li>
<li>Lesson 4: <a href="http://www.steve.gb.com/perl/lesson04.html">Anyone
got some hash? Sorted</a> </li>
<li>Lesson 7: <a href="http://www.steve.gb.com/perl/lesson07.html">Arrays
of hashes of arrays of hashrefs</a> </li>
<li>Lesson 15: <a href="http://www.steve.gb.com/perl/lesson15.html">Tied
up in knots</a> </li>
</ul>
</blockquote>
<p><a href="http://www.perltraining.com.au">Perl Training Australia</a>'s
superlative materials:</p>
<blockquote>
<ul>
<li><i><a href="http://perltraining.com.au/notes.html">
Introduction to Perl</a></i> (<a href="http://www.adobe.com/products/acrobat/readstep2.html/">PDF</a>)</li>
<li><i><a href="http://perltraining.com.au/notes.html">
Intermediate Perl</a></i> (<a href="http://www.adobe.com/products/acrobat/readstep2.html/">PDF</a>)</li>
</ul>
</blockquote>
<p><a href="http://www.plover.com/~mjd/perl/context.html">What is Scalar
Context?</a> by [Dominus]</p>
<p><a href="http://www.plover.com/~mjd/perl/FAQs/references.html">Understand
References Today</a> by [Dominus]</p>
<p><a href="http://web.archive.org/web/20070218230223rn_1/gisle.aas.no/perl/illguts/#hv">Hashes</a>, as explained in
<a href="http://web.archive.org/web/20070218230223rn_1/gisle.aas.no/perl/illguts/">PerlGuts Illustrated</a>, by
<a href="http://gisle.aas.no/">Gisle Aas</a></p>
<p><a href="http://www.perl.com">Perl.com</a>:
<a href="http://www.perl.com/lpt/a/2002/10/01/hashes.html">How Hashes Really
Work</a>, by Abhijit Menon-Sen</p>
<p><a href="http://web.archive.org/web/20060826041456/http://www.5sigma.com/perl/effective_perl.pdf">Effective Perl:
Intermediate and Advanced Topics</a> contains a wealth of information, not
limited to hashes, but also including several pages on
<a href="http://web.archive.org/web/20031011161713/http://www.effectiveperl.com/pegs/">
Joseph N. Hall's PErl Graphical Structures (PEGS)</a>.</p>
<p><a href="http://www.perlarchive.com/___TLC/7026.shtml">Uri Guttman's tutorial on
AUTOVIVIFICATION</a></p>
</blockquote>
<h6>PerlMonks Tutorials:</h6>
<blockquote>
<p>[id://861|the basic datatypes, three], by [root]</p>
<p>[id://125289|Hash Keys (strings or numbers?)], by [robot_tourist]</p>
<p>[id://494836|The Uniqueness of hashes], by [injunjoel]</p>
<p>[id://90647|Multidimensional Arrays], by [CharlesClarkson]</p>
<p>[id://137108|references], by [busunsl] </p>
<p>[id://69927|References quick reference], by [tye]</p>
<p>[id://8070|Object Serialization Basics], by [chromatic]</p>
</blockquote>
<h6>PerlMonks Categorized Questions and Answers:</h6>
<blockquote>
<p>[id://1825|Hashes]</p>
</blockquote>
<h6>Other PerlMonks Nodes:</h6>
<blockquote>
<p>[id://87227|Extracting array of hashes from data] by [nysus]</p>
<p>[id://224434|how to avoid mis-spelling hash keys?], by [Gorilla]</p>
<p>[id://345200|Perl Internals: Hashes], by [Kozz]</p>
<p>[id://439591|help with hashes], by [Anonymous Monk]</p>
<p>[id://445927|The Bad, the Ugly, and the Good of autovivification], by [tlm]</p>
<p>the third item on [pad://tye] is a hash intro</p>
<p>[id://567020|Autovivification trick], by [blazar]</p>
</blockquote>
<h6>perldocs:</h6>
<blockquote>
<p>[doc://perlfaq4]: Data Manipulation - <font size=-1>Manipulating numbers, dates, strings, arrays, hashes, and miscellaneous data issues</font></p>
<p>[doc://perldata]</p>
<p>[doc://perlref]</p>
<p>[doc://perlreftut] }</p>
<p>[doc://perldsc] }<i>Thanks, [wfsp]!</i></p>
<p>[doc://perllol] }</p>
</blockquote>
<h6>Google:</h6>
<blockquote>
<p>[google://perl hash tutorial|Obligatory Google]</p>
</blockquote>
<p> </p>
</blockquote>
<h5>Print:</h5>
<blockquote>
<p>Chapters 5 and 15 of <i><a href="http://www.oreilly.com/catalog/lperl3/index.html">
Learning Perl</a></i> by Randal L. Schwartz and Tom Phoenix</p>
<p>Pages 10-12 and 76-78 of <i>
<a href="http://www.oreilly.com/catalog/pperl3/index.html">Programming Perl</a></i>,
3rd Ed., by Larry Wall, Tom Christiansen, Jon Orwant</p>
<p>Chapter 5 of the <i>
<a href="http://www.oreilly.com/catalog/cookbook/index.html">Perl Cookbook</a></i>,
1st Ed., by Tom Christiansen, Nathan Torkington</p>
</blockquote>
<hr />
<a name="updates"></a>
<p><b>Update:</b> <i>This is only a beginning. I noticed a lack of material on hashes in the [Tutorials] section, and thought I could contribute something, even though it might be one step at a time...</i></p>
<p><b>Update(s):</b> Thanks to [wfsp] for pointing out... I forgot the perldocs!</p>
<blockquote><font size=-2>
<p>2005-07-02: added [doc://perlfaq4], [doc://perlref], [id://125289|125289], [id://137108|137108], [id://69927|69927], [id://224434|224434]</p>
<p>2005-07-06: several links per section; too lazy to enumerate</p>
<p>2005-07-07: added [id://1825], [pad://tye], and some <code>code</code></p>
<p>2005-08-07: added info on [cpan://FakeHash|FakeHash], including code and [http://planetscape.perlmonk.org/FakeHash.png|graphics]</p>
<p>2005-09-12: fixed several broken links, brought to my attention by [Hue-Bond] <i>(Thanks!)</i></p>
<p>2005-12-18: added link to [id://494836|The Uniqueness of hashes], by [injunjoel]</p>
<p>2006-03-25: re-arranged code and references in more logical order; added
anchors; added <code>pic</code> and [wp://SVG] output and info on <code>pic2plot</code></p>
<p>2006-03-26: added link to [id://8070|Object Serialization Basics], by [chromatic]</p>
<p>2006-08-13: added link to [id://567020|Autovivification trick], by [blazar]</p>
<p>2008-12-11: fixed several broken links, brought to my attention by [id://637526] <i>(Thanks!)</i>; also fixed a few b0rked tags</p>
</font></blockquote>
<p> </p>
<p> </p>
<p align="center"><font color="#0080ff">p</font>
<font color="#008bf3">l</font>
<font color="#0097e7">a</font>
<font color="#00a2dc">n</font>
<font color="#00aed0">e</font>
<font color="#00b9c5">t</font>
<font color="#00c5b9">s</font>
<font color="#00d0ae">c</font>
<font color="#00dca2">a</font>
<font color="#00e797">p</font>
<font color="#00f38b">e</font>
</p>