File: perldsc.html

package info (click to toggle)
perl-doc-html 5.26.0-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 39,400 kB
  • sloc: xml: 36; makefile: 7
file content (741 lines) | stat: -rw-r--r-- 97,813 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <title>perldsc - perldoc.perl.org</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta http-equiv="Content-Language" content="en-gb">
  <link rel="search" type="application/opensearchdescription+xml" title="Search perldoc.perl.org" href="/static/search.xml"/>
  <link href="static/css-20100830.css" rel="stylesheet" rev="stylesheet" type="text/css" media="screen">
  <link href="static/exploreperl.css" rel="stylesheet" rev="stylesheet" type="text/css">
</head>

<body onLoad="perldoc.startup();" onPageShow="if (event.persisted) perldoc.startup();">
    <div id="page">
      
      <div id="header">
	<div id="homepage_link">
	  <a href="index.html"></a>
	</div>
	<div id="strapline">
	  Perl Programming Documentation
	</div>
	<div id="download_link" class="download">
	  <a href="http://www.perl.org/get.html">Download Perl</a>
	</div>
	<div id="explore_link" class="download">
	  <a id="explore_anchor" href="#">Explore</a>
	</div>
      </div>
      
      <div id="body">
        <div id="left_column">
          <div class="side_group">
            
	    <div class="side_panel doc_panel">
              <p>Manual</p>
              <ul>
                <li><a href="index-overview.html">Overview</a>
                <li><a href="index-tutorials.html">Tutorials</a>
                <li><a href="index-faq.html">FAQs</a>
                <li><a href="index-history.html">History / Changes</a>
                <li><a href="index-licence.html">License</a>
              </ul>
            </div>
            <div class="side_panel doc_panel">
              <p>Reference</p>
              <ul>
                <li><a href="index-language.html">Language</a>
                <li><a href="index-functions.html">Functions</a>
                <li><a href="perlop.html">Operators</a>
                <li><a href="perlvar.html">Special Variables</a>
                <li><a href="index-pragmas.html">Pragmas</a>
                <li><a href="index-utilities.html">Utilities</a>
                <li><a href="index-internals.html">Internals</a>
                <li><a href="index-platforms.html">Platform Specific</a>
              </ul>
            </div>
            <div class="side_panel doc_panel">
              <p>Modules</p>
              <ul>
		<li>
		
                
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		
                  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		
                  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		
                  
		
                  
		    
		  
		
                  
		
                  
		
		
                    <a href="index-modules-A.html">A</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-B.html">B</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-C.html">C</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-D.html">D</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-E.html">E</a>
                    
                      
                        <li>
                      
                    
                
                    <a href="index-modules-F.html">F</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-G.html">G</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-H.html">H</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-I.html">I</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-L.html">L</a>
                    
                      
                        <li>
                      
                    
                
                    <a href="index-modules-M.html">M</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-N.html">N</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-O.html">O</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-P.html">P</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-S.html">S</a>
                    
                      
                        <li>
                      
                    
                
                    <a href="index-modules-T.html">T</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-U.html">U</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-X.html">X</a>
                    
                
              </ul>
            </div>
            
	      <div class="side_panel doc_panel">
		<p>Tools</p>
		<ul>
		  <li><a href="preferences.html">Preferences</a>
		</ul>
	      </div>
            
          </div>
        </div>
        <div id="centre_column">
          <div id="content_header">
            <div id="title_bar">
              <div id="page_name">
                <h1>perldsc</h1>
              </div>
              <div id="perl_version">
                Perl 5 version 26.0 documentation
              </div>
              <div class="page_links" id="page_links_top">
                <a href="#" onClick="toolbar.goToTop();return false;">Go to top</a>
		
              </div>
	      <div class="page_links" id="page_links_bottom">
		
                  <a href="#" id="page_index_toggle">Show page index</a> &bull;
		
                <a href="#" id="recent_pages_toggle">Show recent pages</a>		
	      </div>
	      <div id="search_form">
		<form action="search.html" method="GET" id="search">
		  <input type="text" name="q" id="search_box" alt="Search">
		</form>
	      </div>
            </div>
            <div id="breadcrumbs">
                
    <a href="index.html">Home</a> &gt;
    
      
        <a href="index-tutorials.html">Tutorials</a> &gt;
      
    
    perldsc
  

            </div>
          </div>
          <div id="content_body">
	    <!--[if lt IE 7]>
 <div class="noscript">
   <p>
     <strong>It looks like you're using Internet Explorer 6. This is a very old
     browser which does not offer full support for modern websites.</strong>
   </p>
   <p>
     Unfortunately this means that this website will not work on
     your computer.
   </p>
   <p>
     Don't miss out though! To view the site (and get a better experience from
     many other websites), simply upgrade to
     <a href="http://www.microsoft.com/windows/Internet-explorer/default.aspx">Internet
Explorer 8</a>
     or download an alternative browser such as
     <a href="http://www.mozilla.com/en-US/firefox/firefox.html">Firefox</a>,
     <a href="http://www.apple.com/safari/download/">Safari</a>, or
     <a href="http://www.google.co.uk/chrome">Google Chrome</a>.
   </p>
   <p>
     All of these browsers are free. If you're using a PC at work, you may
     need to contact your IT administrator.
   </p>
 </div>
<![endif]-->
	    <noscript>
	      <div class="noscript">
	      <p>
                <strong>Please note: Many features of this site require JavaScript. You appear to have JavaScript disabled,
	        or are running a non-JavaScript capable web browser.</strong>
	      </p>
	      <p>
		To get the best experience, please enable JavaScript or download a modern web browser such as <a href="http://www.microsoft.com/windows/Internet-explorer/default.aspx">Internet Explorer 8</a>, <a href="http://www.mozilla.com/en-US/firefox/firefox.html">Firefox</a>, <a href="http://www.apple.com/safari/download/">Safari</a>, or <a href="http://www.google.co.uk/chrome">Google Chrome</a>.
              </p>
	      </div>
	    </noscript>

	    <div id="recent_pages" class="hud_container">
	      <div id="recent_pages_header" class="hud_header">
		<div id="recent_pages_close" class="hud_close"><a href="#" onClick="recentPages.hide();return false;"></a></div>
		<div id="recent_pages_title" class="hud_title"><span class="hud_span_top">Recently read</span></div>
		<div id="recent_pages_topright" class="hud_topright"></div>
	      </div>
	      <div id="recent_pages_content" class="hud_content">
	      </div>
	      <div id="recent_pages_footer" class="hud_footer">
		<div id="recent_pages_bottomleft" class="hud_bottomleft"></div>
		<div id="recent_pages_bottom" class="hud_bottom"><span class="hud_span_bottom"></span></div>
		<div id="recent_pages_resize" class="hud_resize"></div>
	      </div>
	    </div>
  
	    <div id="from_search"></div>
            <h1>perldsc</h1>


  <!--    -->
<ul><li><a href="#NAME">NAME
  </a><li><a href="#DESCRIPTION">DESCRIPTION</a><li><a href="#REFERENCES">REFERENCES
   </a><li><a href="#COMMON-MISTAKES">COMMON MISTAKES</a><li><a href="#CAVEAT-ON-PRECEDENCE">CAVEAT ON PRECEDENCE
 </a><li><a href="#WHY-YOU-SHOULD-ALWAYS-use-strict">WHY YOU SHOULD ALWAYS use strict</a><li><a href="#DEBUGGING">DEBUGGING
 
   
 
 </a><li><a href="#CODE-EXAMPLES">CODE EXAMPLES</a><li><a href="#ARRAYS-OF-ARRAYS">ARRAYS OF ARRAYS
 </a><ul><li><a href="#Declaration-of-an-ARRAY-OF-ARRAYS">Declaration of an ARRAY OF ARRAYS</a><li><a href="#Generation-of-an-ARRAY-OF-ARRAYS">Generation of an ARRAY OF ARRAYS</a><li><a href="#Access-and-Printing-of-an-ARRAY-OF-ARRAYS">Access and Printing of an ARRAY OF ARRAYS</a></ul><li><a href="#HASHES-OF-ARRAYS">HASHES OF ARRAYS
 </a><ul><li><a href="#Declaration-of-a-HASH-OF-ARRAYS">Declaration of a HASH OF ARRAYS</a><li><a href="#Generation-of-a-HASH-OF-ARRAYS">Generation of a HASH OF ARRAYS</a><li><a href="#Access-and-Printing-of-a-HASH-OF-ARRAYS">Access and Printing of a HASH OF ARRAYS</a></ul><li><a href="#ARRAYS-OF-HASHES">ARRAYS OF HASHES
 </a><ul><li><a href="#Declaration-of-an-ARRAY-OF-HASHES">Declaration of an ARRAY OF HASHES</a><li><a href="#Generation-of-an-ARRAY-OF-HASHES">Generation of an ARRAY OF HASHES</a><li><a href="#Access-and-Printing-of-an-ARRAY-OF-HASHES">Access and Printing of an ARRAY OF HASHES</a></ul><li><a href="#HASHES-OF-HASHES">HASHES OF HASHES
 </a><ul><li><a href="#Declaration-of-a-HASH-OF-HASHES">Declaration of a HASH OF HASHES</a><li><a href="#Generation-of-a-HASH-OF-HASHES">Generation of a HASH OF HASHES</a><li><a href="#Access-and-Printing-of-a-HASH-OF-HASHES">Access and Printing of a HASH OF HASHES</a></ul><li><a href="#MORE-ELABORATE-RECORDS">MORE ELABORATE RECORDS
  </a><ul><li><a href="#Declaration-of-MORE-ELABORATE-RECORDS">Declaration of MORE ELABORATE RECORDS</a><li><a href="#Declaration-of-a-HASH-OF-COMPLEX-RECORDS">Declaration of a HASH OF COMPLEX RECORDS</a><li><a href="#Generation-of-a-HASH-OF-COMPLEX-RECORDS">Generation of a HASH OF COMPLEX RECORDS</a></ul><li><a href="#Database-Ties">Database Ties</a><li><a href="#SEE-ALSO">SEE ALSO</a><li><a href="#AUTHOR">AUTHOR</a></ul><a name="NAME"></a><h1>NAME
  </h1>
<p>perldsc - Perl Data Structures Cookbook</p>
<a name="DESCRIPTION"></a><h1>DESCRIPTION</h1>
<p>Perl lets us have complex data structures.  You can write something like
this and all of a sudden, you'd have an array with three dimensions!</p>
<pre class="verbatim"><ol><li>    <a class="l_k" href="functions/for.html">for</a> <a class="l_k" href="functions/my.html">my</a> <span class="i">$x</span> <span class="s">(</span><span class="n">1</span> .. <span class="n">10</span><span class="s">)</span> <span class="s">{</span></li><li>        <a class="l_k" href="functions/for.html">for</a> <a class="l_k" href="functions/my.html">my</a> <span class="i">$y</span> <span class="s">(</span><span class="n">1</span> .. <span class="n">10</span><span class="s">)</span> <span class="s">{</span></li><li>            <a class="l_k" href="functions/for.html">for</a> <a class="l_k" href="functions/my.html">my</a> <span class="i">$z</span> <span class="s">(</span><span class="n">1</span> .. <span class="n">10</span><span class="s">)</span> <span class="s">{</span></li><li>                <span class="i">$AoA</span>[<span class="i">$x</span>][<span class="i">$y</span>][<span class="i">$z</span>] =</li><li>                    <span class="i">$x</span> ** <span class="i">$y</span> + <span class="i">$z</span><span class="sc">;</span></li><li>            <span class="s">}</span></li><li>        <span class="s">}</span></li><li>    <span class="s">}</span></li></ol></pre><p>Alas, however simple this may appear, underneath it's a much more
elaborate construct than meets the eye!</p>
<p>How do you print it out?  Why can't you say just <code class="inline"><a class="l_k" href="functions/print.html">print</a> <span class="i">@AoA</span></code>
?  How do
you sort it?  How can you pass it to a function or get one of these back
from a function?  Is it an object?  Can you save it to disk to read
back later?  How do you access whole rows or columns of that matrix?  Do
all the values have to be numeric?</p>
<p>As you see, it's quite easy to become confused.  While some small portion
of the blame for this can be attributed to the reference-based
implementation, it's really more due to a lack of existing documentation with
examples designed for the beginner.</p>
<p>This document is meant to be a detailed but understandable treatment of the
many different sorts of data structures you might want to develop.  It
should also serve as a cookbook of examples.  That way, when you need to
create one of these complex data structures, you can just pinch, pilfer, or
purloin a drop-in example from here.</p>
<p>Let's look at each of these possible constructs in detail.  There are separate
sections on each of the following:</p>
<ul>
<li><a name="*-arrays-of-arrays"></a><b>arrays of arrays</b>
</li>
<li><a name="*-hashes-of-arrays"></a><b>hashes of arrays</b>
</li>
<li><a name="*-arrays-of-hashes"></a><b>arrays of hashes</b>
</li>
<li><a name="*-hashes-of-hashes"></a><b>hashes of hashes</b>
</li>
<li><a name="*-more-elaborate-constructs"></a><b>more elaborate constructs</b>
</li>
</ul>
<p>But for now, let's look at general issues common to all
these types of data structures.</p>
<a name="REFERENCES"></a><h1>REFERENCES
   </h1>
<p>The most important thing to understand about all data structures in
Perl--including multidimensional arrays--is that even though they might
appear otherwise, Perl <code class="inline"><span class="i">@ARRAY</span></code>
s and <code class="inline"><span class="i">%HASH</span></code>
es are all internally
one-dimensional.  They can hold only scalar values (meaning a string,
number, or a reference).  They cannot directly contain other arrays or
hashes, but instead contain <i>references</i> to other arrays or hashes.
 </p>
<p>You can't use a reference to an array or hash in quite the same way that you
would a real array or hash.  For C or C++ programmers unused to
distinguishing between arrays and pointers to the same, this can be
confusing.  If so, just think of it as the difference between a structure
and a pointer to a structure.</p>
<p>You can (and should) read more about references in <a href="perlref.html">perlref</a>.
Briefly, references are rather like pointers that know what they
point to.  (Objects are also a kind of reference, but we won't be needing
them right away--if ever.)  This means that when you have something which
looks to you like an access to a two-or-more-dimensional array and/or hash,
what's really going on is that the base type is
merely a one-dimensional entity that contains references to the next
level.  It's just that you can <i>use</i> it as though it were a
two-dimensional one.  This is actually the way almost all C
multidimensional arrays work as well.</p>
<pre class="verbatim"><ol><li>    <span class="i">$array</span>[<span class="n">7</span>][<span class="n">12</span>]                       <span class="c"># array of arrays</span></li><li>    <span class="i">$array</span>[<span class="n">7</span>]{<span class="w">string</span>}                   <span class="c"># array of hashes</span></li><li>    <span class="i">$hash</span>{<span class="w">string</span>}[<span class="n">7</span>]                    <span class="c"># hash of arrays</span></li><li>    <span class="i">$hash</span>{<span class="w">string</span>}{<span class="q">&#39;another string&#39;</span>}     <span class="c"># hash of hashes</span></li></ol></pre><p>Now, because the top level contains only references, if you try to print
out your array in with a simple print() function, you'll get something
that doesn't look very nice, like this:</p>
<pre class="verbatim"><ol><li>    <a class="l_k" href="functions/my.html">my</a> <span class="i">@AoA</span> = <span class="s">(</span> <span class="s">[</span><span class="n">2</span><span class="cm">,</span> <span class="n">3</span><span class="s">]</span><span class="cm">,</span> <span class="s">[</span><span class="n">4</span><span class="cm">,</span> <span class="n">5</span><span class="cm">,</span> <span class="n">7</span><span class="s">]</span><span class="cm">,</span> <span class="s">[</span><span class="n">0</span><span class="s">]</span> <span class="s">)</span><span class="sc">;</span></li><li>    <a class="l_k" href="functions/print.html">print</a> <span class="i">$AoA</span>[<span class="n">1</span>][<span class="n">2</span>]<span class="sc">;</span></li><li>  <span class="n">7</span></li><li>    <a class="l_k" href="functions/print.html">print</a> <span class="i">@AoA</span><span class="sc">;</span></li><li>  <span class="i">ARRAY</span><span class="s">(</span><span class="n">0x83c38</span><span class="s">)</span><span class="i">ARRAY</span><span class="s">(</span><span class="n">0x8b194</span><span class="s">)</span><span class="i">ARRAY</span><span class="s">(</span><span class="n">0x8b1d0</span><span class="s">)</span></li></ol></pre><p>That's because Perl doesn't (ever) implicitly dereference your variables.
If you want to get at the thing a reference is referring to, then you have
to do this yourself using either prefix typing indicators, like
<code class="inline"><span class="i">$</span>{<span class="i">$blah</span>}</code>
, <code class="inline"><span class="i">@</span>{<span class="i">$blah</span>}</code>
, <code class="inline"><span class="i">@</span>{<span class="i">$blah</span>[<span class="i">$i</span>]}</code>
, or else postfix pointer arrows,
like <code class="inline"><span class="i">$a</span>-&gt;[<span class="n">3</span>]</code>
, <code class="inline"><span class="i">$h</span>-&gt;{<span class="w">fred</span>}</code>
, or even <code class="inline"><span class="i">$ob</span><span class="i">-&gt;method</span><span class="s">(</span><span class="s">)</span>-&gt;[<span class="n">3</span>]</code>
.</p>
<a name="COMMON-MISTAKES"></a><h1>COMMON MISTAKES</h1>
<p>The two most common mistakes made in constructing something like
an array of arrays is either accidentally counting the number of
elements or else taking a reference to the same memory location
repeatedly.  Here's the case where you just get the count instead
of a nested array:</p>
<pre class="verbatim"><ol><li>    <a class="l_k" href="functions/for.html">for</a> <a class="l_k" href="functions/my.html">my</a> <span class="i">$i</span> <span class="s">(</span><span class="n">1</span>..<span class="n">10</span><span class="s">)</span> <span class="s">{</span></li><li>        <a class="l_k" href="functions/my.html">my</a> <span class="i">@array</span> = <span class="i">somefunc</span><span class="s">(</span><span class="i">$i</span><span class="s">)</span><span class="sc">;</span></li><li>        <span class="i">$AoA</span>[<span class="i">$i</span>] = <span class="i">@array</span><span class="sc">;</span>      <span class="c"># WRONG!</span></li><li>    <span class="s">}</span></li></ol></pre><p>That's just the simple case of assigning an array to a scalar and getting
its element count.  If that's what you really and truly want, then you
might do well to consider being a tad more explicit about it, like this:</p>
<pre class="verbatim"><ol><li>    <a class="l_k" href="functions/for.html">for</a> <a class="l_k" href="functions/my.html">my</a> <span class="i">$i</span> <span class="s">(</span><span class="n">1</span>..<span class="n">10</span><span class="s">)</span> <span class="s">{</span></li><li>        <a class="l_k" href="functions/my.html">my</a> <span class="i">@array</span> = <span class="i">somefunc</span><span class="s">(</span><span class="i">$i</span><span class="s">)</span><span class="sc">;</span></li><li>        <span class="i">$counts</span>[<span class="i">$i</span>] = <a class="l_k" href="functions/scalar.html">scalar</a> <span class="i">@array</span><span class="sc">;</span></li><li>    <span class="s">}</span></li></ol></pre><p>Here's the case of taking a reference to the same memory location
again and again:</p>
<pre class="verbatim"><ol><li>    <span class="c"># Either without strict or having an outer-scope my @array;</span></li><li>    <span class="c"># declaration.</span></li><li></li><li>    <a class="l_k" href="functions/for.html">for</a> <a class="l_k" href="functions/my.html">my</a> <span class="i">$i</span> <span class="s">(</span><span class="n">1</span>..<span class="n">10</span><span class="s">)</span> <span class="s">{</span></li><li>        <span class="i">@array</span> = <span class="i">somefunc</span><span class="s">(</span><span class="i">$i</span><span class="s">)</span><span class="sc">;</span></li><li>        <span class="i">$AoA</span>[<span class="i">$i</span>] = \<span class="i">@array</span><span class="sc">;</span>     <span class="c"># WRONG!</span></li><li>    <span class="s">}</span></li></ol></pre><p>So, what's the big problem with that?  It looks right, doesn't it?
After all, I just told you that you need an array of references, so by
golly, you've made me one!</p>
<p>Unfortunately, while this is true, it's still broken.  All the references
in @AoA refer to the <i>very same place</i>, and they will therefore all hold
whatever was last in @array!  It's similar to the problem demonstrated in
the following C program:</p>
<pre class="verbatim"><ol><li>    <span class="c">#include &lt;pwd.h&gt;</span></li><li>    <span class="i">main</span><span class="s">(</span><span class="s">)</span> <span class="s">{</span></li><li>        <span class="w">struct</span> <span class="w">passwd</span> *<a class="l_k" href="functions/getpwnam.html">getpwnam</a><span class="s">(</span><span class="s">)</span><span class="cm">,</span> <span class="i">*rp</span><span class="cm">,</span> <span class="i">*dp</span><span class="sc">;</span></li><li>        <span class="w">rp</span> = <a class="l_k" href="functions/getpwnam.html">getpwnam</a><span class="s">(</span><span class="q">&quot;root&quot;</span><span class="s">)</span><span class="sc">;</span></li><li>        <span class="w">dp</span> = <a class="l_k" href="functions/getpwnam.html">getpwnam</a><span class="s">(</span><span class="q">&quot;daemon&quot;</span><span class="s">)</span><span class="sc">;</span></li><li></li><li>        <a class="l_k" href="functions/printf.html">printf</a><span class="s">(</span><span class="q">&quot;daemon name is %s\nroot name is %s\n&quot;</span><span class="cm">,</span></li><li>                <span class="w">dp</span><span class="w">-&gt;pw_name</span><span class="cm">,</span> <span class="w">rp</span><span class="w">-&gt;pw_name</span><span class="s">)</span><span class="sc">;</span></li><li>    <span class="s">}</span></li></ol></pre><p>Which will print</p>
<pre class="verbatim"><ol><li>    <span class="w">daemon</span> <span class="w">name</span> <span class="w">is</span> <span class="w">daemon</span></li><li>    <span class="w">root</span> <span class="w">name</span> <span class="w">is</span> <span class="w">daemon</span></li></ol></pre><p>The problem is that both <code class="inline"><span class="w">rp</span></code>
 and <code class="inline"><span class="w">dp</span></code>
 are pointers to the same location
in memory!  In C, you'd have to remember to malloc() yourself some new
memory.  In Perl, you'll want to use the array constructor <code class="inline"><span class="s">[</span><span class="s">]</span></code>
 or the
hash constructor <code class="inline"><span class="s">{</span><span class="s">}</span></code>
 instead.   Here's the right way to do the preceding
broken code fragments:
 </p>
<pre class="verbatim"><ol><li>    <span class="c"># Either without strict or having an outer-scope my @array;</span></li><li>    <span class="c"># declaration.</span></li><li></li><li>    <a class="l_k" href="functions/for.html">for</a> <a class="l_k" href="functions/my.html">my</a> <span class="i">$i</span> <span class="s">(</span><span class="n">1</span>..<span class="n">10</span><span class="s">)</span> <span class="s">{</span></li><li>        <span class="i">@array</span> = <span class="i">somefunc</span><span class="s">(</span><span class="i">$i</span><span class="s">)</span><span class="sc">;</span></li><li>        <span class="i">$AoA</span>[<span class="i">$i</span>] = <span class="s">[</span> <span class="i">@array</span> <span class="s">]</span><span class="sc">;</span></li><li>    <span class="s">}</span></li></ol></pre><p>The square brackets make a reference to a new array with a <i>copy</i>
of what's in @array at the time of the assignment.  This is what
you want.</p>
<p>Note that this will produce something similar, but it's
much harder to read:</p>
<pre class="verbatim"><ol><li>    <span class="c"># Either without strict or having an outer-scope my @array;</span></li><li>    <span class="c"># declaration.</span></li><li>    <a class="l_k" href="functions/for.html">for</a> <a class="l_k" href="functions/my.html">my</a> <span class="i">$i</span> <span class="s">(</span><span class="n">1</span>..<span class="n">10</span><span class="s">)</span> <span class="s">{</span></li><li>        <span class="i">@array</span> = <span class="n">0</span> .. <span class="i">$i</span><span class="sc">;</span></li><li>        <span class="i">@</span>{<span class="i">$AoA</span>[<span class="i">$i</span>]} = <span class="i">@array</span><span class="sc">;</span></li><li>    <span class="s">}</span></li></ol></pre><p>Is it the same?  Well, maybe so--and maybe not.  The subtle difference
is that when you assign something in square brackets, you know for sure
it's always a brand new reference with a new <i>copy</i> of the data.
Something else could be going on in this new case with the <code class="inline"><span class="i">@</span>{<span class="i">$AoA</span>[<span class="i">$i</span>]}</code>

dereference on the left-hand-side of the assignment.  It all depends on
whether <code class="inline"><span class="i">$AoA</span>[<span class="i">$i</span>]</code>
 had been undefined to start with, or whether it
already contained a reference.  If you had already populated @AoA with
references, as in</p>
<pre class="verbatim"><ol><li>    <span class="i">$AoA</span>[<span class="n">3</span>] = \<span class="i">@another_array</span><span class="sc">;</span></li></ol></pre><p>Then the assignment with the indirection on the left-hand-side would
use the existing reference that was already there:</p>
<pre class="verbatim"><ol><li>    <span class="i">@</span>{<span class="i">$AoA</span>[<span class="n">3</span>]} = <span class="i">@array</span><span class="sc">;</span></li></ol></pre><p>Of course, this <i>would</i> have the "interesting" effect of clobbering
@another_array.  (Have you ever noticed how when a programmer says
something is "interesting", that rather than meaning "intriguing",
they're disturbingly more apt to mean that it's "annoying",
"difficult", or both?  :-)</p>
<p>So just remember always to use the array or hash constructors with <code class="inline"><span class="s">[</span><span class="s">]</span></code>

or <code class="inline"><span class="s">{</span><span class="s">}</span></code>
, and you'll be fine, although it's not always optimally
efficient.</p>
<p>Surprisingly, the following dangerous-looking construct will
actually work out fine:</p>
<pre class="verbatim"><ol><li>    <a class="l_k" href="functions/for.html">for</a> <a class="l_k" href="functions/my.html">my</a> <span class="i">$i</span> <span class="s">(</span><span class="n">1</span>..<span class="n">10</span><span class="s">)</span> <span class="s">{</span></li><li>        <a class="l_k" href="functions/my.html">my</a> <span class="i">@array</span> = <span class="i">somefunc</span><span class="s">(</span><span class="i">$i</span><span class="s">)</span><span class="sc">;</span></li><li>        <span class="i">$AoA</span>[<span class="i">$i</span>] = \<span class="i">@array</span><span class="sc">;</span></li><li>    <span class="s">}</span></li></ol></pre><p>That's because my() is more of a run-time statement than it is a
compile-time declaration <i>per se</i>.  This means that the my() variable is
remade afresh each time through the loop.  So even though it <i>looks</i> as
though you stored the same variable reference each time, you actually did
not!  This is a subtle distinction that can produce more efficient code at
the risk of misleading all but the most experienced of programmers.  So I
usually advise against teaching it to beginners.  In fact, except for
passing arguments to functions, I seldom like to see the gimme-a-reference
operator (backslash) used much at all in code.  Instead, I advise
beginners that they (and most of the rest of us) should try to use the
much more easily understood constructors <code class="inline"><span class="s">[</span><span class="s">]</span></code>
 and <code class="inline"><span class="s">{</span><span class="s">}</span></code>
 instead of
relying upon lexical (or dynamic) scoping and hidden reference-counting to
do the right thing behind the scenes.</p>
<p>In summary:</p>
<pre class="verbatim"><ol><li>    <span class="i">$AoA</span>[<span class="i">$i</span>] = <span class="s">[</span> <span class="i">@array</span> <span class="s">]</span><span class="sc">;</span>     <span class="c"># usually best</span></li><li>    <span class="i">$AoA</span>[<span class="i">$i</span>] = \<span class="i">@array</span><span class="sc">;</span>        <span class="c"># perilous; just how my() was that array?</span></li><li>    <span class="i">@</span>{ <span class="i">$AoA</span>[<span class="i">$i</span>] } = <span class="i">@array</span><span class="sc">;</span>    <span class="c"># way too tricky for most programmers</span></li></ol></pre><a name="CAVEAT-ON-PRECEDENCE"></a><h1>CAVEAT ON PRECEDENCE
 </h1>
<p>Speaking of things like <code class="inline"><span class="i">@</span>{<span class="i">$AoA</span>[<span class="i">$i</span>]}</code>
, the following are actually the
same thing:
</p>
<pre class="verbatim"><ol><li>    <span class="i">$aref</span>-&gt;[<span class="n">2</span>][<span class="n">2</span>]       <span class="c"># clear</span></li><li>    <span class="i">$$aref</span>[<span class="n">2</span>][<span class="n">2</span>]        <span class="c"># confusing</span></li></ol></pre><p>That's because Perl's precedence rules on its five prefix dereferencers
(which look like someone swearing: <code class="inline"><span class="i">$ @</span> * <span class="i">% &amp;</span></code>
) make them bind more
tightly than the postfix subscripting brackets or braces!  This will no
doubt come as a great shock to the C or C++ programmer, who is quite
accustomed to using <code class="inline"><span class="i">*a</span>[<span class="w">i</span>]</code>
 to mean what's pointed to by the <i>i'th</i>
element of <code class="inline"><span class="w">a</span></code>
.  That is, they first take the subscript, and only then
dereference the thing at that subscript.  That's fine in C, but this isn't C.</p>
<p>The seemingly equivalent construct in Perl, <code class="inline"><span class="i">$$aref</span>[<span class="i">$i</span>]</code>
 first does
the deref of $aref, making it take $aref as a reference to an
array, and then dereference that, and finally tell you the <i>i'th</i> value
of the array pointed to by $AoA. If you wanted the C notion, you'd have to
write <code class="inline"><span class="i">$</span>{<span class="i">$AoA</span>[<span class="i">$i</span>]}</code>
 to force the <code class="inline"><span class="i">$AoA</span>[<span class="i">$i</span>]</code>
 to get evaluated first
before the leading <code class="inline"><span class="i">$</span></code>
 dereferencer.</p>
<a name="WHY-YOU-SHOULD-ALWAYS-use-strict"></a><h1>WHY YOU SHOULD ALWAYS <code class="inline"><a class="l_k" href="functions/use.html">use</a> <span class="w">strict</span></code>
</h1>
<p>If this is starting to sound scarier than it's worth, relax.  Perl has
some features to help you avoid its most common pitfalls.  The best
way to avoid getting confused is to start every program like this:</p>
<pre class="verbatim"><ol><li>    <span class="c">#!/usr/bin/perl -w</span></li><li>    <a class="l_k" href="functions/use.html">use</a> <span class="w">strict</span><span class="sc">;</span></li></ol></pre><p>This way, you'll be forced to declare all your variables with my() and
also disallow accidental "symbolic dereferencing".  Therefore if you'd done
this:</p>
<pre class="verbatim"><ol><li>    <a class="l_k" href="functions/my.html">my</a> <span class="i">$aref</span> = <span class="s">[</span></li><li>        <span class="s">[</span> <span class="q">&quot;fred&quot;</span><span class="cm">,</span> <span class="q">&quot;barney&quot;</span><span class="cm">,</span> <span class="q">&quot;pebbles&quot;</span><span class="cm">,</span> <span class="q">&quot;bambam&quot;</span><span class="cm">,</span> <span class="q">&quot;dino&quot;</span><span class="cm">,</span> <span class="s">]</span><span class="cm">,</span></li><li>        <span class="s">[</span> <span class="q">&quot;homer&quot;</span><span class="cm">,</span> <span class="q">&quot;bart&quot;</span><span class="cm">,</span> <span class="q">&quot;marge&quot;</span><span class="cm">,</span> <span class="q">&quot;maggie&quot;</span><span class="cm">,</span> <span class="s">]</span><span class="cm">,</span></li><li>        <span class="s">[</span> <span class="q">&quot;george&quot;</span><span class="cm">,</span> <span class="q">&quot;jane&quot;</span><span class="cm">,</span> <span class="q">&quot;elroy&quot;</span><span class="cm">,</span> <span class="q">&quot;judy&quot;</span><span class="cm">,</span> <span class="s">]</span><span class="cm">,</span></li><li>    <span class="s">]</span><span class="sc">;</span></li><li></li><li>    <a class="l_k" href="functions/print.html">print</a> <span class="i">$aref</span>[<span class="n">2</span>][<span class="n">2</span>]<span class="sc">;</span></li></ol></pre><p>The compiler would immediately flag that as an error <i>at compile time</i>,
because you were accidentally accessing <code class="inline"><span class="i">@aref</span></code>
, an undeclared
variable, and it would thereby remind you to write instead:</p>
<pre class="verbatim"><ol><li>    <a class="l_k" href="functions/print.html">print</a> <span class="i">$aref</span>-&gt;[<span class="n">2</span>][<span class="n">2</span>]</li></ol></pre><a name="DEBUGGING"></a><h1>DEBUGGING
 
   
 
 </h1>
<p>You can use the debugger's <code class="inline"><span class="w">x</span></code>
 command to dump out complex data structures.
For example, given the assignment to $AoA above, here's the debugger output:</p>
<pre class="verbatim"><ol><li>    <span class="w">DB</span><span class="q">&lt;1&gt;</span> x <span class="i">$AoA</span></li><li>    <span class="i">$AoA</span> = <span class="i">ARRAY</span><span class="s">(</span><span class="n">0x13b5a0</span><span class="s">)</span></li><li>       <span class="n">0</span>  <span class="i">ARRAY</span><span class="s">(</span><span class="n">0x1f0a24</span><span class="s">)</span></li><li>          <span class="n">0</span>  <span class="q">&#39;fred&#39;</span></li><li>          <span class="n">1</span>  <span class="q">&#39;barney&#39;</span></li><li>          <span class="n">2</span>  <span class="q">&#39;pebbles&#39;</span></li><li>          <span class="n">3</span>  <span class="q">&#39;bambam&#39;</span></li><li>          <span class="n">4</span>  <span class="q">&#39;dino&#39;</span></li><li>       <span class="n">1</span>  <span class="i">ARRAY</span><span class="s">(</span><span class="n">0x13b558</span><span class="s">)</span></li><li>          <span class="n">0</span>  <span class="q">&#39;homer&#39;</span></li><li>          <span class="n">1</span>  <span class="q">&#39;bart&#39;</span></li><li>          <span class="n">2</span>  <span class="q">&#39;marge&#39;</span></li><li>          <span class="n">3</span>  <span class="q">&#39;maggie&#39;</span></li><li>       <span class="n">2</span>  <span class="i">ARRAY</span><span class="s">(</span><span class="n">0x13b540</span><span class="s">)</span></li><li>          <span class="n">0</span>  <span class="q">&#39;george&#39;</span></li><li>          <span class="n">1</span>  <span class="q">&#39;jane&#39;</span></li><li>          <span class="n">2</span>  <span class="q">&#39;elroy&#39;</span></li><li>          <span class="n">3</span>  <span class="q">&#39;judy&#39;</span></li></ol></pre><a name="CODE-EXAMPLES"></a><h1>CODE EXAMPLES</h1>
<p>Presented with little comment (these will get their own manpages someday)
here are short code examples illustrating access of various
types of data structures.</p>
<a name="ARRAYS-OF-ARRAYS"></a><h1>ARRAYS OF ARRAYS
 </h1>
<a name="Declaration-of-an-ARRAY-OF-ARRAYS"></a><h2>Declaration of an ARRAY OF ARRAYS</h2>
<pre class="verbatim"><ol><li> <span class="i">@AoA</span> = <span class="s">(</span></li><li>        <span class="s">[</span> <span class="q">&quot;fred&quot;</span><span class="cm">,</span> <span class="q">&quot;barney&quot;</span> <span class="s">]</span><span class="cm">,</span></li><li>        <span class="s">[</span> <span class="q">&quot;george&quot;</span><span class="cm">,</span> <span class="q">&quot;jane&quot;</span><span class="cm">,</span> <span class="q">&quot;elroy&quot;</span> <span class="s">]</span><span class="cm">,</span></li><li>        <span class="s">[</span> <span class="q">&quot;homer&quot;</span><span class="cm">,</span> <span class="q">&quot;marge&quot;</span><span class="cm">,</span> <span class="q">&quot;bart&quot;</span> <span class="s">]</span><span class="cm">,</span></li><li>      <span class="s">)</span><span class="sc">;</span></li></ol></pre><a name="Generation-of-an-ARRAY-OF-ARRAYS"></a><h2>Generation of an ARRAY OF ARRAYS</h2>
<pre class="verbatim"><ol><li> <span class="c"># reading from file</span></li><li> while <span class="s">(</span> &lt;&gt; <span class="s">)</span> <span class="s">{</span></li><li>     <a class="l_k" href="functions/push.html">push</a> <span class="i">@AoA</span><span class="cm">,</span> <span class="s">[</span> <a class="l_k" href="functions/split.html">split</a> <span class="s">]</span><span class="sc">;</span></li><li> <span class="s">}</span></li><li></li><li> <span class="c"># calling a function</span></li><li> for <span class="i">$i</span> <span class="s">(</span> <span class="n">1</span> .. <span class="n">10</span> <span class="s">)</span> <span class="s">{</span></li><li>     <span class="i">$AoA</span>[<span class="i">$i</span>] = <span class="s">[</span> <span class="i">somefunc</span><span class="s">(</span><span class="i">$i</span><span class="s">)</span> <span class="s">]</span><span class="sc">;</span></li><li> <span class="s">}</span></li><li></li><li> <span class="c"># using temp vars</span></li><li> for <span class="i">$i</span> <span class="s">(</span> <span class="n">1</span> .. <span class="n">10</span> <span class="s">)</span> <span class="s">{</span></li><li>     <span class="i">@tmp</span> = <span class="i">somefunc</span><span class="s">(</span><span class="i">$i</span><span class="s">)</span><span class="sc">;</span></li><li>     <span class="i">$AoA</span>[<span class="i">$i</span>] = <span class="s">[</span> <span class="i">@tmp</span> <span class="s">]</span><span class="sc">;</span></li><li> <span class="s">}</span></li><li></li><li> <span class="c"># add to an existing row</span></li><li> <a class="l_k" href="functions/push.html">push</a> <span class="i">@</span>{ <span class="i">$AoA</span>[<span class="n">0</span>] }<span class="cm">,</span> <span class="q">&quot;wilma&quot;</span><span class="cm">,</span> <span class="q">&quot;betty&quot;</span><span class="sc">;</span></li></ol></pre><a name="Access-and-Printing-of-an-ARRAY-OF-ARRAYS"></a><h2>Access and Printing of an ARRAY OF ARRAYS</h2>
<pre class="verbatim"><ol><li> <span class="c"># one element</span></li><li> <span class="i">$AoA</span>[<span class="n">0</span>][<span class="n">0</span>] = <span class="q">&quot;Fred&quot;</span><span class="sc">;</span></li><li></li><li> <span class="c"># another element</span></li><li> <span class="i">$AoA</span>[<span class="n">1</span>][<span class="n">1</span>] =~ <span class="q">s/(\w)/\u$1/</span><span class="sc">;</span></li><li></li><li> <span class="c"># print the whole thing with refs</span></li><li> for <span class="i">$aref</span> <span class="s">(</span> <span class="i">@AoA</span> <span class="s">)</span> <span class="s">{</span></li><li>     <a class="l_k" href="functions/print.html">print</a> <span class="q">&quot;\t [ @$aref ],\n&quot;</span><span class="sc">;</span></li><li> <span class="s">}</span></li><li></li><li> <span class="c"># print the whole thing with indices</span></li><li> for <span class="i">$i</span> <span class="s">(</span> <span class="n">0</span> .. <span class="i">$#AoA</span> <span class="s">)</span> <span class="s">{</span></li><li>     <a class="l_k" href="functions/print.html">print</a> <span class="q">&quot;\t [ @{$AoA[$i]} ],\n&quot;</span><span class="sc">;</span></li><li> <span class="s">}</span></li><li></li><li> <span class="c"># print the whole thing one at a time</span></li><li> for <span class="i">$i</span> <span class="s">(</span> <span class="n">0</span> .. <span class="i">$#AoA</span> <span class="s">)</span> <span class="s">{</span></li><li>     for <span class="i">$j</span> <span class="s">(</span> <span class="n">0</span> .. <span class="i">$#</span>{ <span class="i">$AoA</span>[<span class="i">$i</span>] } <span class="s">)</span> <span class="s">{</span></li><li>         <a class="l_k" href="functions/print.html">print</a> <span class="q">&quot;elt $i $j is $AoA[$i][$j]\n&quot;</span><span class="sc">;</span></li><li>     <span class="s">}</span></li><li> <span class="s">}</span></li></ol></pre><a name="HASHES-OF-ARRAYS"></a><h1>HASHES OF ARRAYS
 </h1>
<a name="Declaration-of-a-HASH-OF-ARRAYS"></a><h2>Declaration of a HASH OF ARRAYS</h2>
<pre class="verbatim"><ol><li> <span class="i">%HoA</span> = <span class="s">(</span></li><li>        <span class="w">flintstones</span>        <span class="cm">=&gt;</span> <span class="s">[</span> <span class="q">&quot;fred&quot;</span><span class="cm">,</span> <span class="q">&quot;barney&quot;</span> <span class="s">]</span><span class="cm">,</span></li><li>        <span class="w">jetsons</span>            <span class="cm">=&gt;</span> <span class="s">[</span> <span class="q">&quot;george&quot;</span><span class="cm">,</span> <span class="q">&quot;jane&quot;</span><span class="cm">,</span> <span class="q">&quot;elroy&quot;</span> <span class="s">]</span><span class="cm">,</span></li><li>        <span class="w">simpsons</span>           <span class="cm">=&gt;</span> <span class="s">[</span> <span class="q">&quot;homer&quot;</span><span class="cm">,</span> <span class="q">&quot;marge&quot;</span><span class="cm">,</span> <span class="q">&quot;bart&quot;</span> <span class="s">]</span><span class="cm">,</span></li><li>      <span class="s">)</span><span class="sc">;</span></li></ol></pre><a name="Generation-of-a-HASH-OF-ARRAYS"></a><h2>Generation of a HASH OF ARRAYS</h2>
<pre class="verbatim"><ol><li> <span class="c"># reading from file</span></li><li> <span class="c"># flintstones: fred barney wilma dino</span></li><li> while <span class="s">(</span> &lt;&gt; <span class="s">)</span> <span class="s">{</span></li><li>     <a class="l_k" href="functions/next.html">next</a> unless <span class="q">s/^(.*?):\s*//</span><span class="sc">;</span></li><li>     <span class="i">$HoA</span>{<span class="i">$1</span>} = <span class="s">[</span> <a class="l_k" href="functions/split.html">split</a> <span class="s">]</span><span class="sc">;</span></li><li> <span class="s">}</span></li><li></li><li> <span class="c"># reading from file; more temps</span></li><li> <span class="c"># flintstones: fred barney wilma dino</span></li><li> while <span class="s">(</span> <span class="i">$line</span> = &lt;&gt; <span class="s">)</span> <span class="s">{</span></li><li>     <span class="s">(</span><span class="i">$who</span><span class="cm">,</span> <span class="i">$rest</span><span class="s">)</span> = <a class="l_k" href="functions/split.html">split</a> <span class="q">/:\s*/</span><span class="cm">,</span> <span class="i">$line</span><span class="cm">,</span> <span class="n">2</span><span class="sc">;</span></li><li>     <span class="i">@fields</span> = <a class="l_k" href="functions/split.html">split</a> <span class="q">&#39; &#39;</span><span class="cm">,</span> <span class="i">$rest</span><span class="sc">;</span></li><li>     <span class="i">$HoA</span>{<span class="i">$who</span>} = <span class="s">[</span> <span class="i">@fields</span> <span class="s">]</span><span class="sc">;</span></li><li> <span class="s">}</span></li><li></li><li> <span class="c"># calling a function that returns a list</span></li><li> for <span class="i">$group</span> <span class="s">(</span> <span class="q">&quot;simpsons&quot;</span><span class="cm">,</span> <span class="q">&quot;jetsons&quot;</span><span class="cm">,</span> <span class="q">&quot;flintstones&quot;</span> <span class="s">)</span> <span class="s">{</span></li><li>     <span class="i">$HoA</span>{<span class="i">$group</span>} = <span class="s">[</span> <span class="i">get_family</span><span class="s">(</span><span class="i">$group</span><span class="s">)</span> <span class="s">]</span><span class="sc">;</span></li><li> <span class="s">}</span></li><li></li><li> <span class="c"># likewise, but using temps</span></li><li> for <span class="i">$group</span> <span class="s">(</span> <span class="q">&quot;simpsons&quot;</span><span class="cm">,</span> <span class="q">&quot;jetsons&quot;</span><span class="cm">,</span> <span class="q">&quot;flintstones&quot;</span> <span class="s">)</span> <span class="s">{</span></li><li>     <span class="i">@members</span> = <span class="i">get_family</span><span class="s">(</span><span class="i">$group</span><span class="s">)</span><span class="sc">;</span></li><li>     <span class="i">$HoA</span>{<span class="i">$group</span>} = <span class="s">[</span> <span class="i">@members</span> <span class="s">]</span><span class="sc">;</span></li><li> <span class="s">}</span></li><li></li><li> <span class="c"># append new members to an existing family</span></li><li> <a class="l_k" href="functions/push.html">push</a> <span class="i">@</span>{ <span class="i">$HoA</span>{<span class="q">&quot;flintstones&quot;</span>} }<span class="cm">,</span> <span class="q">&quot;wilma&quot;</span><span class="cm">,</span> <span class="q">&quot;betty&quot;</span><span class="sc">;</span></li></ol></pre><a name="Access-and-Printing-of-a-HASH-OF-ARRAYS"></a><h2>Access and Printing of a HASH OF ARRAYS</h2>
<pre class="verbatim"><ol><li> <span class="c"># one element</span></li><li> <span class="i">$HoA</span>{<span class="w">flintstones</span>}[<span class="n">0</span>] = <span class="q">&quot;Fred&quot;</span><span class="sc">;</span></li><li></li><li> <span class="c"># another element</span></li><li> <span class="i">$HoA</span>{<span class="w">simpsons</span>}[<span class="n">1</span>] =~ <span class="q">s/(\w)/\u$1/</span><span class="sc">;</span></li><li></li><li> <span class="c"># print the whole thing</span></li><li> <a class="l_k" href="functions/foreach.html">foreach</a> <span class="i">$family</span> <span class="s">(</span> <a class="l_k" href="functions/keys.html">keys</a> <span class="i">%HoA</span> <span class="s">)</span> <span class="s">{</span></li><li>     <a class="l_k" href="functions/print.html">print</a> <span class="q">&quot;$family: @{ $HoA{$family} }\n&quot;</span></li><li> <span class="s">}</span></li><li></li><li> <span class="c"># print the whole thing with indices</span></li><li> <a class="l_k" href="functions/foreach.html">foreach</a> <span class="i">$family</span> <span class="s">(</span> <a class="l_k" href="functions/keys.html">keys</a> <span class="i">%HoA</span> <span class="s">)</span> <span class="s">{</span></li><li>     <a class="l_k" href="functions/print.html">print</a> <span class="q">&quot;family: &quot;</span><span class="sc">;</span></li><li>     <a class="l_k" href="functions/foreach.html">foreach</a> <span class="i">$i</span> <span class="s">(</span> <span class="n">0</span> .. <span class="i">$#</span>{ <span class="i">$HoA</span>{<span class="i">$family</span>} } <span class="s">)</span> <span class="s">{</span></li><li>         <a class="l_k" href="functions/print.html">print</a> <span class="q">&quot; $i = $HoA{$family}[$i]&quot;</span><span class="sc">;</span></li><li>     <span class="s">}</span></li><li>     <a class="l_k" href="functions/print.html">print</a> <span class="q">&quot;\n&quot;</span><span class="sc">;</span></li><li> <span class="s">}</span></li><li></li><li> <span class="c"># print the whole thing sorted by number of members</span></li><li> <a class="l_k" href="functions/foreach.html">foreach</a> <span class="i">$family</span> <span class="s">(</span> <a class="l_k" href="functions/sort.html">sort</a> <span class="s">{</span> <span class="i">@</span>{<span class="i">$HoA</span>{<span class="i">$b</span>}} &lt;=&gt; <span class="i">@</span>{<span class="i">$HoA</span>{<span class="i">$a</span>}} <span class="s">}</span> <a class="l_k" href="functions/keys.html">keys</a> <span class="i">%HoA</span> <span class="s">)</span> <span class="s">{</span></li><li>     <a class="l_k" href="functions/print.html">print</a> <span class="q">&quot;$family: @{ $HoA{$family} }\n&quot;</span></li><li> <span class="s">}</span></li><li></li><li> <span class="c"># print the whole thing sorted by number of members and name</span></li><li> <a class="l_k" href="functions/foreach.html">foreach</a> <span class="i">$family</span> <span class="s">(</span> <a class="l_k" href="functions/sort.html">sort</a> <span class="s">{</span></li><li>                            <span class="i">@</span>{<span class="i">$HoA</span>{<span class="i">$b</span>}} &lt;=&gt; <span class="i">@</span>{<span class="i">$HoA</span>{<span class="i">$a</span>}}</li><li>                                        ||</li><li>                                    <span class="i">$a</span> <a class="l_k" href="functions/cmp.html">cmp</a> <span class="i">$b</span></li><li>            <span class="s">}</span> <a class="l_k" href="functions/keys.html">keys</a> <span class="i">%HoA</span> <span class="s">)</span></li><li> <span class="s">{</span></li><li>     <a class="l_k" href="functions/print.html">print</a> <span class="q">&quot;$family: &quot;</span><span class="cm">,</span> <a class="l_k" href="functions/join.html">join</a><span class="s">(</span><span class="q">&quot;, &quot;</span><span class="cm">,</span> <a class="l_k" href="functions/sort.html">sort</a> <span class="i">@</span>{ <span class="i">$HoA</span>{<span class="i">$family</span>} }<span class="s">)</span><span class="cm">,</span> <span class="q">&quot;\n&quot;</span><span class="sc">;</span></li><li> <span class="s">}</span></li></ol></pre><a name="ARRAYS-OF-HASHES"></a><h1>ARRAYS OF HASHES
 </h1>
<a name="Declaration-of-an-ARRAY-OF-HASHES"></a><h2>Declaration of an ARRAY OF HASHES</h2>
<pre class="verbatim"><ol><li> <span class="i">@AoH</span> = <span class="s">(</span></li><li>        <span class="s">{</span></li><li>            <span class="w">Lead</span>     <span class="cm">=&gt;</span> <span class="q">&quot;fred&quot;</span><span class="cm">,</span></li><li>            <span class="w">Friend</span>   <span class="cm">=&gt;</span> <span class="q">&quot;barney&quot;</span><span class="cm">,</span></li><li>        <span class="s">}</span><span class="cm">,</span></li><li>        <span class="s">{</span></li><li>            <span class="w">Lead</span>     <span class="cm">=&gt;</span> <span class="q">&quot;george&quot;</span><span class="cm">,</span></li><li>            <span class="w">Wife</span>     <span class="cm">=&gt;</span> <span class="q">&quot;jane&quot;</span><span class="cm">,</span></li><li>            <span class="w">Son</span>      <span class="cm">=&gt;</span> <span class="q">&quot;elroy&quot;</span><span class="cm">,</span></li><li>        <span class="s">}</span><span class="cm">,</span></li><li>        <span class="s">{</span></li><li>            <span class="w">Lead</span>     <span class="cm">=&gt;</span> <span class="q">&quot;homer&quot;</span><span class="cm">,</span></li><li>            <span class="w">Wife</span>     <span class="cm">=&gt;</span> <span class="q">&quot;marge&quot;</span><span class="cm">,</span></li><li>            <span class="w">Son</span>      <span class="cm">=&gt;</span> <span class="q">&quot;bart&quot;</span><span class="cm">,</span></li><li>        <span class="s">}</span></li><li>  <span class="s">)</span><span class="sc">;</span></li></ol></pre><a name="Generation-of-an-ARRAY-OF-HASHES"></a><h2>Generation of an ARRAY OF HASHES</h2>
<pre class="verbatim"><ol><li> <span class="c"># reading from file</span></li><li> <span class="c"># format: LEAD=fred FRIEND=barney</span></li><li> while <span class="s">(</span> &lt;&gt; <span class="s">)</span> <span class="s">{</span></li><li>     <span class="i">$rec</span> = <span class="s">{</span><span class="s">}</span><span class="sc">;</span></li><li>     for <span class="i">$field</span> <span class="s">(</span> <a class="l_k" href="functions/split.html">split</a> <span class="s">)</span> <span class="s">{</span></li><li>         <span class="s">(</span><span class="i">$key</span><span class="cm">,</span> <span class="i">$value</span><span class="s">)</span> = <a class="l_k" href="functions/split.html">split</a> <span class="q">/=/</span><span class="cm">,</span> <span class="i">$field</span><span class="sc">;</span></li><li>         <span class="i">$rec</span>-&gt;{<span class="i">$key</span>} = <span class="i">$value</span><span class="sc">;</span></li><li>     <span class="s">}</span></li><li>     <a class="l_k" href="functions/push.html">push</a> <span class="i">@AoH</span><span class="cm">,</span> <span class="i">$rec</span><span class="sc">;</span></li><li> <span class="s">}</span></li><li></li><li></li><li> <span class="c"># reading from file</span></li><li> <span class="c"># format: LEAD=fred FRIEND=barney</span></li><li> <span class="c"># no temp</span></li><li> while <span class="s">(</span> &lt;&gt; <span class="s">)</span> <span class="s">{</span></li><li>     <a class="l_k" href="functions/push.html">push</a> <span class="i">@AoH</span><span class="cm">,</span> <span class="s">{</span> <a class="l_k" href="functions/split.html">split</a> <span class="q">/[\s+=]/</span> <span class="s">}</span><span class="sc">;</span></li><li> <span class="s">}</span></li><li></li><li> <span class="c"># calling a function  that returns a key/value pair list, like</span></li><li> <span class="c"># &quot;lead&quot;,&quot;fred&quot;,&quot;daughter&quot;,&quot;pebbles&quot;</span></li><li> while <span class="s">(</span> <span class="i">%fields</span> = <span class="i">getnextpairset</span><span class="s">(</span><span class="s">)</span> <span class="s">)</span> <span class="s">{</span></li><li>     <a class="l_k" href="functions/push.html">push</a> <span class="i">@AoH</span><span class="cm">,</span> <span class="s">{</span> <span class="i">%fields</span> <span class="s">}</span><span class="sc">;</span></li><li> <span class="s">}</span></li><li></li><li> <span class="c"># likewise, but using no temp vars</span></li><li> while <span class="s">(</span>&lt;&gt;<span class="s">)</span> <span class="s">{</span></li><li>     <a class="l_k" href="functions/push.html">push</a> <span class="i">@AoH</span><span class="cm">,</span> <span class="s">{</span> <span class="i">parsepairs</span><span class="s">(</span><span class="i">$_</span><span class="s">)</span> <span class="s">}</span><span class="sc">;</span></li><li> <span class="s">}</span></li><li></li><li> <span class="c"># add key/value to an element</span></li><li> <span class="i">$AoH</span>[<span class="n">0</span>]{<span class="w">pet</span>} = <span class="q">&quot;dino&quot;</span><span class="sc">;</span></li><li> <span class="i">$AoH</span>[<span class="n">2</span>]{<span class="w">pet</span>} = <span class="q">&quot;santa&#39;s little helper&quot;</span><span class="sc">;</span></li></ol></pre><a name="Access-and-Printing-of-an-ARRAY-OF-HASHES"></a><h2>Access and Printing of an ARRAY OF HASHES</h2>
<pre class="verbatim"><ol><li> <span class="c"># one element</span></li><li> <span class="i">$AoH</span>[<span class="n">0</span>]{<span class="w">lead</span>} = <span class="q">&quot;fred&quot;</span><span class="sc">;</span></li><li></li><li> <span class="c"># another element</span></li><li> <span class="i">$AoH</span>[<span class="n">1</span>]{<span class="w">lead</span>} =~ <span class="q">s/(\w)/\u$1/</span><span class="sc">;</span></li><li></li><li> <span class="c"># print the whole thing with refs</span></li><li> for <span class="i">$href</span> <span class="s">(</span> <span class="i">@AoH</span> <span class="s">)</span> <span class="s">{</span></li><li>     <a class="l_k" href="functions/print.html">print</a> <span class="q">&quot;{ &quot;</span><span class="sc">;</span></li><li>     for <span class="i">$role</span> <span class="s">(</span> <a class="l_k" href="functions/keys.html">keys</a> <span class="i">%$href</span> <span class="s">)</span> <span class="s">{</span></li><li>         <a class="l_k" href="functions/print.html">print</a> <span class="q">&quot;$role=$href-&gt;{$role} &quot;</span><span class="sc">;</span></li><li>     <span class="s">}</span></li><li>     <a class="l_k" href="functions/print.html">print</a> <span class="q">&quot;}\n&quot;</span><span class="sc">;</span></li><li> <span class="s">}</span></li><li></li><li> <span class="c"># print the whole thing with indices</span></li><li> for <span class="i">$i</span> <span class="s">(</span> <span class="n">0</span> .. <span class="i">$#AoH</span> <span class="s">)</span> <span class="s">{</span></li><li>     <a class="l_k" href="functions/print.html">print</a> <span class="q">&quot;$i is { &quot;</span><span class="sc">;</span></li><li>     for <span class="i">$role</span> <span class="s">(</span> <a class="l_k" href="functions/keys.html">keys</a> <span class="i">%</span>{ <span class="i">$AoH</span>[<span class="i">$i</span>] } <span class="s">)</span> <span class="s">{</span></li><li>         <a class="l_k" href="functions/print.html">print</a> <span class="q">&quot;$role=$AoH[$i]{$role} &quot;</span><span class="sc">;</span></li><li>     <span class="s">}</span></li><li>     <a class="l_k" href="functions/print.html">print</a> <span class="q">&quot;}\n&quot;</span><span class="sc">;</span></li><li> <span class="s">}</span></li><li></li><li> <span class="c"># print the whole thing one at a time</span></li><li> for <span class="i">$i</span> <span class="s">(</span> <span class="n">0</span> .. <span class="i">$#AoH</span> <span class="s">)</span> <span class="s">{</span></li><li>     for <span class="i">$role</span> <span class="s">(</span> <a class="l_k" href="functions/keys.html">keys</a> <span class="i">%</span>{ <span class="i">$AoH</span>[<span class="i">$i</span>] } <span class="s">)</span> <span class="s">{</span></li><li>         <a class="l_k" href="functions/print.html">print</a> <span class="q">&quot;elt $i $role is $AoH[$i]{$role}\n&quot;</span><span class="sc">;</span></li><li>     <span class="s">}</span></li><li> <span class="s">}</span></li></ol></pre><a name="HASHES-OF-HASHES"></a><h1>HASHES OF HASHES
 </h1>
<a name="Declaration-of-a-HASH-OF-HASHES"></a><h2>Declaration of a HASH OF HASHES</h2>
<pre class="verbatim"><ol><li> <span class="i">%HoH</span> = <span class="s">(</span></li><li>        <span class="w">flintstones</span> <span class="cm">=&gt;</span> <span class="s">{</span></li><li>                <span class="w">lead</span>      <span class="cm">=&gt;</span> <span class="q">&quot;fred&quot;</span><span class="cm">,</span></li><li>                <span class="w">pal</span>       <span class="cm">=&gt;</span> <span class="q">&quot;barney&quot;</span><span class="cm">,</span></li><li>        <span class="s">}</span><span class="cm">,</span></li><li>        <span class="w">jetsons</span>     <span class="cm">=&gt;</span> <span class="s">{</span></li><li>                <span class="w">lead</span>      <span class="cm">=&gt;</span> <span class="q">&quot;george&quot;</span><span class="cm">,</span></li><li>                <span class="w">wife</span>      <span class="cm">=&gt;</span> <span class="q">&quot;jane&quot;</span><span class="cm">,</span></li><li>                <span class="q">&quot;his boy&quot;</span> <span class="cm">=&gt;</span> <span class="q">&quot;elroy&quot;</span><span class="cm">,</span></li><li>        <span class="s">}</span><span class="cm">,</span></li><li>        <span class="w">simpsons</span>    <span class="cm">=&gt;</span> <span class="s">{</span></li><li>                <span class="w">lead</span>      <span class="cm">=&gt;</span> <span class="q">&quot;homer&quot;</span><span class="cm">,</span></li><li>                <span class="w">wife</span>      <span class="cm">=&gt;</span> <span class="q">&quot;marge&quot;</span><span class="cm">,</span></li><li>                <span class="w">kid</span>       <span class="cm">=&gt;</span> <span class="q">&quot;bart&quot;</span><span class="cm">,</span></li><li>        <span class="s">}</span><span class="cm">,</span></li><li> <span class="s">)</span><span class="sc">;</span></li></ol></pre><a name="Generation-of-a-HASH-OF-HASHES"></a><h2>Generation of a HASH OF HASHES</h2>
<pre class="verbatim"><ol><li> # reading from file</li><li> # flintstones: lead=fred pal=barney wife=wilma pet=dino</li><li> while ( &lt;&gt; ) {</li><li>     next unless s/^(.*?):\s*//;</li><li>     $who = $1;</li><li>     for $field ( split ) {</li><li>         ($key, $value) = split /=/, $field;</li><li>         $HoH{$who}{$key} = $value;</li><li>     }</li><li></li><li></li><li> # reading from file; more temps</li><li> while ( &lt;&gt; ) {</li><li>     next unless s/^(.*?):\s*//;</li><li>     $who = $1;</li><li>     $rec = {};</li><li>     $HoH{$who} = $rec;</li><li>     for $field ( split ) {</li><li>         ($key, $value) = split /=/, $field;</li><li>         $rec-&gt;{$key} = $value;</li><li>     }</li><li> }</li><li></li><li> # calling a function  that returns a key,value hash</li><li> for $group ( "simpsons", "jetsons", "flintstones" ) {</li><li>     $HoH{$group} = { get_family($group) };</li><li> }</li><li></li><li> # likewise, but using temps</li><li> for $group ( "simpsons", "jetsons", "flintstones" ) {</li><li>     %members = get_family($group);</li><li>     $HoH{$group} = { %members };</li><li> }</li><li></li><li> # append new members to an existing family</li><li> %new_folks = (</li><li>     wife =&gt; "wilma",</li><li>     pet  =&gt; "dino",</li><li> );</li><li></li><li> for $what (keys %new_folks) {</li><li>     $HoH{flintstones}{$what} = $new_folks{$what};</li><li> }</li></ol></pre><a name="Access-and-Printing-of-a-HASH-OF-HASHES"></a><h2>Access and Printing of a HASH OF HASHES</h2>
<pre class="verbatim"><ol><li> <span class="c"># one element</span></li><li> <span class="i">$HoH</span>{<span class="w">flintstones</span>}{<span class="w">wife</span>} = <span class="q">&quot;wilma&quot;</span><span class="sc">;</span></li><li></li><li> <span class="c"># another element</span></li><li> <span class="i">$HoH</span>{<span class="w">simpsons</span>}{<span class="w">lead</span>} =~ <span class="q">s/(\w)/\u$1/</span><span class="sc">;</span></li><li></li><li> <span class="c"># print the whole thing</span></li><li> <a class="l_k" href="functions/foreach.html">foreach</a> <span class="i">$family</span> <span class="s">(</span> <a class="l_k" href="functions/keys.html">keys</a> <span class="i">%HoH</span> <span class="s">)</span> <span class="s">{</span></li><li>     <a class="l_k" href="functions/print.html">print</a> <span class="q">&quot;$family: { &quot;</span><span class="sc">;</span></li><li>     <a class="l_k" href="functions/for.html">for</a> <span class="i">$role</span> <span class="s">(</span> <a class="l_k" href="functions/keys.html">keys</a> <span class="i">%</span>{ <span class="i">$HoH</span>{<span class="i">$family</span>} } <span class="s">)</span> <span class="s">{</span></li><li>         <a class="l_k" href="functions/print.html">print</a> <span class="q">&quot;$role=$HoH{$family}{$role} &quot;</span><span class="sc">;</span></li><li>     <span class="s">}</span></li><li>     <a class="l_k" href="functions/print.html">print</a> <span class="q">&quot;}\n&quot;</span><span class="sc">;</span></li><li> <span class="s">}</span></li><li></li><li> <span class="c"># print the whole thing  somewhat sorted</span></li><li> <a class="l_k" href="functions/foreach.html">foreach</a> <span class="i">$family</span> <span class="s">(</span> <a class="l_k" href="functions/sort.html">sort</a> <a class="l_k" href="functions/keys.html">keys</a> <span class="i">%HoH</span> <span class="s">)</span> <span class="s">{</span></li><li>     <a class="l_k" href="functions/print.html">print</a> <span class="q">&quot;$family: { &quot;</span><span class="sc">;</span></li><li>     <a class="l_k" href="functions/for.html">for</a> <span class="i">$role</span> <span class="s">(</span> <a class="l_k" href="functions/sort.html">sort</a> <a class="l_k" href="functions/keys.html">keys</a> <span class="i">%</span>{ <span class="i">$HoH</span>{<span class="i">$family</span>} } <span class="s">)</span> <span class="s">{</span></li><li>         <a class="l_k" href="functions/print.html">print</a> <span class="q">&quot;$role=$HoH{$family}{$role} &quot;</span><span class="sc">;</span></li><li>     <span class="s">}</span></li><li>     <a class="l_k" href="functions/print.html">print</a> <span class="q">&quot;}\n&quot;</span><span class="sc">;</span></li><li> <span class="s">}</span></li><li></li><li></li><li> <span class="c"># print the whole thing sorted by number of members</span></li><li> <a class="l_k" href="functions/foreach.html">foreach</a> <span class="i">$family</span> <span class="s">(</span> <a class="l_k" href="functions/sort.html">sort</a> <span class="s">{</span> <a class="l_k" href="functions/keys.html">keys</a> <span class="i">%</span>{<span class="i">$HoH</span>{<span class="i">$b</span>}} &lt;=&gt; <a class="l_k" href="functions/keys.html">keys</a> <span class="i">%</span>{<span class="i">$HoH</span>{<span class="i">$a</span>}} <span class="s">}</span></li><li>                                                             <a class="l_k" href="functions/keys.html">keys</a> <span class="i">%HoH</span> <span class="s">)</span></li><li> <span class="s">{</span></li><li>     <a class="l_k" href="functions/print.html">print</a> <span class="q">&quot;$family: { &quot;</span><span class="sc">;</span></li><li>     <a class="l_k" href="functions/for.html">for</a> <span class="i">$role</span> <span class="s">(</span> <a class="l_k" href="functions/sort.html">sort</a> <a class="l_k" href="functions/keys.html">keys</a> <span class="i">%</span>{ <span class="i">$HoH</span>{<span class="i">$family</span>} } <span class="s">)</span> <span class="s">{</span></li><li>         <a class="l_k" href="functions/print.html">print</a> <span class="q">&quot;$role=$HoH{$family}{$role} &quot;</span><span class="sc">;</span></li><li>     <span class="s">}</span></li><li>     <a class="l_k" href="functions/print.html">print</a> <span class="q">&quot;}\n&quot;</span><span class="sc">;</span></li><li> <span class="s">}</span></li><li></li><li> <span class="c"># establish a sort order (rank) for each role</span></li><li> <span class="i">$i</span> = <span class="n">0</span><span class="sc">;</span></li><li> <a class="l_k" href="functions/for.html">for</a> <span class="s">(</span> <span class="q">qw(lead wife son daughter pal pet)</span> <span class="s">)</span> <span class="s">{</span> <span class="i">$rank</span>{<span class="i">$_</span>} = ++<span class="i">$i</span> <span class="s">}</span></li><li></li><li> <span class="c"># now print the whole thing sorted by number of members</span></li><li> <a class="l_k" href="functions/foreach.html">foreach</a> <span class="i">$family</span> <span class="s">(</span> <a class="l_k" href="functions/sort.html">sort</a> <span class="s">{</span> <a class="l_k" href="functions/keys.html">keys</a> <span class="i">%</span>{ <span class="i">$HoH</span>{<span class="i">$b</span>} } &lt;=&gt; <a class="l_k" href="functions/keys.html">keys</a> <span class="i">%</span>{ <span class="i">$HoH</span>{<span class="i">$a</span>} } <span class="s">}</span></li><li>                                                             <a class="l_k" href="functions/keys.html">keys</a> <span class="i">%HoH</span> <span class="s">)</span></li><li> <span class="s">{</span></li><li>     <a class="l_k" href="functions/print.html">print</a> <span class="q">&quot;$family: { &quot;</span><span class="sc">;</span></li><li>     <span class="c"># and print these according to rank order</span></li><li>     <a class="l_k" href="functions/for.html">for</a> <span class="i">$role</span> <span class="s">(</span> <a class="l_k" href="functions/sort.html">sort</a> <span class="s">{</span> <span class="i">$rank</span>{<span class="i">$a</span>} &lt;=&gt; <span class="i">$rank</span>{<span class="i">$b</span>} <span class="s">}</span></li><li>                                               <a class="l_k" href="functions/keys.html">keys</a> <span class="i">%</span>{ <span class="i">$HoH</span>{<span class="i">$family</span>} } <span class="s">)</span></li><li>     <span class="s">{</span></li><li>         <a class="l_k" href="functions/print.html">print</a> <span class="q">&quot;$role=$HoH{$family}{$role} &quot;</span><span class="sc">;</span></li><li>     <span class="s">}</span></li><li>     <a class="l_k" href="functions/print.html">print</a> <span class="q">&quot;}\n&quot;</span><span class="sc">;</span></li><li> <span class="s">}</span></li></ol></pre><a name="MORE-ELABORATE-RECORDS"></a><h1>MORE ELABORATE RECORDS
  </h1>
<a name="Declaration-of-MORE-ELABORATE-RECORDS"></a><h2>Declaration of MORE ELABORATE RECORDS</h2>
<p>Here's a sample showing how to create and use a record whose fields are of
many different sorts:</p>
<pre class="verbatim"><ol><li>     <span class="i">$rec</span> = <span class="s">{</span></li><li>         <span class="w">TEXT</span>      <span class="cm">=&gt;</span> <span class="i">$string</span><span class="cm">,</span></li><li>         <span class="w">SEQUENCE</span>  <span class="cm">=&gt;</span> <span class="s">[</span> <span class="i">@old_values</span> <span class="s">]</span><span class="cm">,</span></li><li>         <span class="w">LOOKUP</span>    <span class="cm">=&gt;</span> <span class="s">{</span> <span class="i">%some_table</span> <span class="s">}</span><span class="cm">,</span></li><li>         <span class="w">THATCODE</span>  <span class="cm">=&gt;</span> \<span class="i">&amp;some_function</span><span class="cm">,</span></li><li>         <span class="w">THISCODE</span>  <span class="cm">=&gt;</span> <a class="l_k" href="functions/sub.html">sub</a> <span class="s">{</span> <span class="i">$_</span>[<span class="n">0</span>] ** <span class="i">$_</span>[<span class="n">1</span>] <span class="s">}</span><span class="cm">,</span></li><li>         <span class="w">HANDLE</span>    <span class="cm">=&gt;</span> \<span class="i">*STDOUT</span><span class="cm">,</span></li><li>     <span class="s">}</span><span class="sc">;</span></li><li></li><li>     <a class="l_k" href="functions/print.html">print</a> <span class="i">$rec</span>-&gt;{<span class="w">TEXT</span>}<span class="sc">;</span></li><li></li><li>     <a class="l_k" href="functions/print.html">print</a> <span class="i">$rec</span>-&gt;{<span class="w">SEQUENCE</span>}[<span class="n">0</span>]<span class="sc">;</span></li><li>     <span class="i">$last</span> = <a class="l_k" href="functions/pop.html">pop</a> <span class="i">@</span> { <span class="i">$rec</span>-&gt;{<span class="w">SEQUENCE</span>} }<span class="sc">;</span></li><li></li><li>     <a class="l_k" href="functions/print.html">print</a> <span class="i">$rec</span>-&gt;{<span class="w">LOOKUP</span>}{<span class="q">&quot;key&quot;</span>}<span class="sc">;</span></li><li>     <span class="s">(</span><span class="i">$first_k</span><span class="cm">,</span> <span class="i">$first_v</span><span class="s">)</span> = <a class="l_k" href="functions/each.html">each</a> <span class="i">%</span>{ <span class="i">$rec</span>-&gt;{<span class="w">LOOKUP</span>} }<span class="sc">;</span></li><li></li><li>     <span class="i">$answer</span> = <span class="i">$rec</span>-&gt;{<span class="w">THATCODE</span>}-&gt;<span class="s">(</span><span class="i">$arg</span><span class="s">)</span><span class="sc">;</span></li><li>     <span class="i">$answer</span> = <span class="i">$rec</span>-&gt;{<span class="w">THISCODE</span>}-&gt;<span class="s">(</span><span class="i">$arg1</span><span class="cm">,</span> <span class="i">$arg2</span><span class="s">)</span><span class="sc">;</span></li><li></li><li>     <span class="c"># careful of extra block braces on fh ref</span></li><li>     <a class="l_k" href="functions/print.html">print</a> <span class="s">{</span> <span class="i">$rec</span>-&gt;{<span class="w">HANDLE</span>} <span class="s">}</span> <span class="q">&quot;a string\n&quot;</span><span class="sc">;</span></li><li></li><li>     <a class="l_k" href="functions/use.html">use</a> <span class="w">FileHandle</span><span class="sc">;</span></li><li>     <span class="i">$rec</span>-&gt;{<span class="w">HANDLE</span>}<span class="i">-&gt;autoflush</span><span class="s">(</span><span class="n">1</span><span class="s">)</span><span class="sc">;</span></li><li>     <span class="i">$rec</span>-&gt;{<span class="w">HANDLE</span>}<span class="i">-&gt;print</span><span class="s">(</span><span class="q">&quot; a string\n&quot;</span><span class="s">)</span><span class="sc">;</span></li></ol></pre><a name="Declaration-of-a-HASH-OF-COMPLEX-RECORDS"></a><h2>Declaration of a HASH OF COMPLEX RECORDS</h2>
<pre class="verbatim"><ol><li>     <span class="i">%TV</span> = <span class="s">(</span></li><li>        <span class="w">flintstones</span> <span class="cm">=&gt;</span> <span class="s">{</span></li><li>            <span class="w">series</span>   <span class="cm">=&gt;</span> <span class="q">&quot;flintstones&quot;</span><span class="cm">,</span></li><li>            <span class="w">nights</span>   <span class="cm">=&gt;</span> <span class="s">[</span> <span class="q">qw(monday thursday friday)</span> <span class="s">]</span><span class="cm">,</span></li><li>            <span class="w">members</span>  <span class="cm">=&gt;</span> <span class="s">[</span></li><li>                <span class="s">{</span> <span class="w">name</span> <span class="cm">=&gt;</span> <span class="q">&quot;fred&quot;</span><span class="cm">,</span>    <span class="w">role</span> <span class="cm">=&gt;</span> <span class="q">&quot;lead&quot;</span><span class="cm">,</span> <span class="w">age</span>  <span class="cm">=&gt;</span> <span class="n">36</span><span class="cm">,</span> <span class="s">}</span><span class="cm">,</span></li><li>                <span class="s">{</span> <span class="w">name</span> <span class="cm">=&gt;</span> <span class="q">&quot;wilma&quot;</span><span class="cm">,</span>   <span class="w">role</span> <span class="cm">=&gt;</span> <span class="q">&quot;wife&quot;</span><span class="cm">,</span> <span class="w">age</span>  <span class="cm">=&gt;</span> <span class="n">31</span><span class="cm">,</span> <span class="s">}</span><span class="cm">,</span></li><li>                <span class="s">{</span> <span class="w">name</span> <span class="cm">=&gt;</span> <span class="q">&quot;pebbles&quot;</span><span class="cm">,</span> <span class="w">role</span> <span class="cm">=&gt;</span> <span class="q">&quot;kid&quot;</span><span class="cm">,</span>  <span class="w">age</span>  <span class="cm">=&gt;</span>  <span class="n">4</span><span class="cm">,</span> <span class="s">}</span><span class="cm">,</span></li><li>            <span class="s">]</span><span class="cm">,</span></li><li>        <span class="s">}</span><span class="cm">,</span></li><li></li><li>        <span class="w">jetsons</span>     <span class="cm">=&gt;</span> <span class="s">{</span></li><li>            <span class="w">series</span>   <span class="cm">=&gt;</span> <span class="q">&quot;jetsons&quot;</span><span class="cm">,</span></li><li>            <span class="w">nights</span>   <span class="cm">=&gt;</span> <span class="s">[</span> <span class="q">qw(wednesday saturday)</span> <span class="s">]</span><span class="cm">,</span></li><li>            <span class="w">members</span>  <span class="cm">=&gt;</span> <span class="s">[</span></li><li>                <span class="s">{</span> <span class="w">name</span> <span class="cm">=&gt;</span> <span class="q">&quot;george&quot;</span><span class="cm">,</span>  <span class="w">role</span> <span class="cm">=&gt;</span> <span class="q">&quot;lead&quot;</span><span class="cm">,</span> <span class="w">age</span>  <span class="cm">=&gt;</span> <span class="n">41</span><span class="cm">,</span> <span class="s">}</span><span class="cm">,</span></li><li>                <span class="s">{</span> <span class="w">name</span> <span class="cm">=&gt;</span> <span class="q">&quot;jane&quot;</span><span class="cm">,</span>    <span class="w">role</span> <span class="cm">=&gt;</span> <span class="q">&quot;wife&quot;</span><span class="cm">,</span> <span class="w">age</span>  <span class="cm">=&gt;</span> <span class="n">39</span><span class="cm">,</span> <span class="s">}</span><span class="cm">,</span></li><li>                <span class="s">{</span> <span class="w">name</span> <span class="cm">=&gt;</span> <span class="q">&quot;elroy&quot;</span><span class="cm">,</span>   <span class="w">role</span> <span class="cm">=&gt;</span> <span class="q">&quot;kid&quot;</span><span class="cm">,</span>  <span class="w">age</span>  <span class="cm">=&gt;</span>  <span class="n">9</span><span class="cm">,</span> <span class="s">}</span><span class="cm">,</span></li><li>            <span class="s">]</span><span class="cm">,</span></li><li>         <span class="s">}</span><span class="cm">,</span></li><li></li><li>        <span class="w">simpsons</span>    <span class="cm">=&gt;</span> <span class="s">{</span></li><li>            <span class="w">series</span>   <span class="cm">=&gt;</span> <span class="q">&quot;simpsons&quot;</span><span class="cm">,</span></li><li>            <span class="w">nights</span>   <span class="cm">=&gt;</span> <span class="s">[</span> <span class="q">qw(monday)</span> <span class="s">]</span><span class="cm">,</span></li><li>            <span class="w">members</span>  <span class="cm">=&gt;</span> <span class="s">[</span></li><li>                <span class="s">{</span> <span class="w">name</span> <span class="cm">=&gt;</span> <span class="q">&quot;homer&quot;</span><span class="cm">,</span> <span class="w">role</span> <span class="cm">=&gt;</span> <span class="q">&quot;lead&quot;</span><span class="cm">,</span> <span class="w">age</span>  <span class="cm">=&gt;</span> <span class="n">34</span><span class="cm">,</span> <span class="s">}</span><span class="cm">,</span></li><li>                <span class="s">{</span> <span class="w">name</span> <span class="cm">=&gt;</span> <span class="q">&quot;marge&quot;</span><span class="cm">,</span> <span class="w">role</span> <span class="cm">=&gt;</span> <span class="q">&quot;wife&quot;</span><span class="cm">,</span> <span class="w">age</span> <span class="cm">=&gt;</span> <span class="n">37</span><span class="cm">,</span> <span class="s">}</span><span class="cm">,</span></li><li>                <span class="s">{</span> <span class="w">name</span> <span class="cm">=&gt;</span> <span class="q">&quot;bart&quot;</span><span class="cm">,</span>  <span class="w">role</span> <span class="cm">=&gt;</span> <span class="q">&quot;kid&quot;</span><span class="cm">,</span>  <span class="w">age</span>  <span class="cm">=&gt;</span>  <span class="n">11</span><span class="cm">,</span> <span class="s">}</span><span class="cm">,</span></li><li>            <span class="s">]</span><span class="cm">,</span></li><li>         <span class="s">}</span><span class="cm">,</span></li><li>      <span class="s">)</span><span class="sc">;</span></li></ol></pre><a name="Generation-of-a-HASH-OF-COMPLEX-RECORDS"></a><h2>Generation of a HASH OF COMPLEX RECORDS</h2>
<pre class="verbatim"><ol><li>     <span class="c"># reading from file</span></li><li>     <span class="c"># this is most easily done by having the file itself be</span></li><li>     <span class="c"># in the raw data format as shown above.  perl is happy</span></li><li>     <span class="c"># to parse complex data structures if declared as data, so</span></li><li>     <span class="c"># sometimes it&#39;s easiest to do that</span></li><li></li><li>     <span class="c"># here&#39;s a piece by piece build up</span></li><li>     <span class="i">$rec</span> = <span class="s">{</span><span class="s">}</span><span class="sc">;</span></li><li>     <span class="i">$rec</span>-&gt;{<span class="w">series</span>} = <span class="q">&quot;flintstones&quot;</span><span class="sc">;</span></li><li>     <span class="i">$rec</span>-&gt;{<span class="w">nights</span>} = <span class="s">[</span> <span class="i">find_days</span><span class="s">(</span><span class="s">)</span> <span class="s">]</span><span class="sc">;</span></li><li></li><li>     <span class="i">@members</span> = <span class="s">(</span><span class="s">)</span><span class="sc">;</span></li><li>     <span class="c"># assume this file in field=value syntax</span></li><li>     while <span class="s">(</span>&lt;&gt;<span class="s">)</span> <span class="s">{</span></li><li>         <span class="i">%fields</span> = <a class="l_k" href="functions/split.html">split</a> <span class="q">/[\s=]+/</span><span class="sc">;</span></li><li>         <a class="l_k" href="functions/push.html">push</a> <span class="i">@members</span><span class="cm">,</span> <span class="s">{</span> <span class="i">%fields</span> <span class="s">}</span><span class="sc">;</span></li><li>     <span class="s">}</span></li><li>     <span class="i">$rec</span>-&gt;{<span class="w">members</span>} = <span class="s">[</span> <span class="i">@members</span> <span class="s">]</span><span class="sc">;</span></li><li></li><li>     <span class="c"># now remember the whole thing</span></li><li>     <span class="i">$TV</span>{ <span class="i">$rec</span>-&gt;{<span class="w">series</span>} } = <span class="i">$rec</span><span class="sc">;</span></li><li></li><li>     <span class="c">###########################################################</span></li><li>     <span class="c"># now, you might want to make interesting extra fields that</span></li><li>     <span class="c"># include pointers back into the same data structure so if</span></li><li>     <span class="c"># change one piece, it changes everywhere, like for example</span></li><li>     <span class="c"># if you wanted a {kids} field that was a reference</span></li><li>     <span class="c"># to an array of the kids&#39; records without having duplicate</span></li><li>     <span class="c"># records and thus update problems.</span></li><li>     <span class="c">###########################################################</span></li><li>     foreach <span class="i">$family</span> <span class="s">(</span><a class="l_k" href="functions/keys.html">keys</a> <span class="i">%TV</span><span class="s">)</span> <span class="s">{</span></li><li>         <span class="i">$rec</span> = <span class="i">$TV</span>{<span class="i">$family</span>}<span class="sc">;</span> <span class="c"># temp pointer</span></li><li>         <span class="i">@kids</span> = <span class="s">(</span><span class="s">)</span><span class="sc">;</span></li><li>         for <span class="i">$person</span> <span class="s">(</span> <span class="i">@</span>{ <span class="i">$rec</span>-&gt;{<span class="w">members</span>} } <span class="s">)</span> <span class="s">{</span></li><li>             if <span class="s">(</span><span class="i">$person</span>-&gt;{<span class="w">role</span>} =~ <span class="q">/kid|son|daughter/</span><span class="s">)</span> <span class="s">{</span></li><li>                 <a class="l_k" href="functions/push.html">push</a> <span class="i">@kids</span><span class="cm">,</span> <span class="i">$person</span><span class="sc">;</span></li><li>             <span class="s">}</span></li><li>         <span class="s">}</span></li><li>         <span class="c"># REMEMBER: $rec and $TV{$family} point to same data!!</span></li><li>         <span class="i">$rec</span>-&gt;{<span class="w">kids</span>} = <span class="s">[</span> <span class="i">@kids</span> <span class="s">]</span><span class="sc">;</span></li><li>     <span class="s">}</span></li><li></li><li>     <span class="c"># you copied the array, but the array itself contains pointers</span></li><li>     <span class="c"># to uncopied objects. this means that if you make bart get</span></li><li>     <span class="c"># older via</span></li><li></li><li>     <span class="i">$TV</span>{<span class="w">simpsons</span>}{<span class="w">kids</span>}[<span class="n">0</span>]{<span class="w">age</span>}++<span class="sc">;</span></li><li></li><li>     <span class="c"># then this would also change in</span></li><li>     <a class="l_k" href="functions/print.html">print</a> <span class="i">$TV</span>{<span class="w">simpsons</span>}{<span class="w">members</span>}[<span class="n">2</span>]{<span class="w">age</span>}<span class="sc">;</span></li><li></li><li>     <span class="c"># because $TV{simpsons}{kids}[0] and $TV{simpsons}{members}[2]</span></li><li>     <span class="c"># both point to the same underlying anonymous hash table</span></li><li></li><li>     <span class="c"># print the whole thing</span></li><li>     foreach <span class="i">$family</span> <span class="s">(</span> <a class="l_k" href="functions/keys.html">keys</a> <span class="i">%TV</span> <span class="s">)</span> <span class="s">{</span></li><li>         <a class="l_k" href="functions/print.html">print</a> <span class="q">&quot;the $family&quot;</span><span class="sc">;</span></li><li>         <a class="l_k" href="functions/print.html">print</a> <span class="q">&quot; is on during @{ $TV{$family}{nights} }\n&quot;</span><span class="sc">;</span></li><li>         <a class="l_k" href="functions/print.html">print</a> <span class="q">&quot;its members are:\n&quot;</span><span class="sc">;</span></li><li>         for <span class="i">$who</span> <span class="s">(</span> <span class="i">@</span>{ <span class="i">$TV</span>{<span class="i">$family</span>}{<span class="w">members</span>} } <span class="s">)</span> <span class="s">{</span></li><li>             <a class="l_k" href="functions/print.html">print</a> <span class="q">&quot; $who-&gt;{name} ($who-&gt;{role}), age $who-&gt;{age}\n&quot;</span><span class="sc">;</span></li><li>         <span class="s">}</span></li><li>         <a class="l_k" href="functions/print.html">print</a> <span class="q">&quot;it turns out that $TV{$family}{lead} has &quot;</span><span class="sc">;</span></li><li>         <a class="l_k" href="functions/print.html">print</a> <a class="l_k" href="functions/scalar.html">scalar</a> <span class="s">(</span> <span class="i">@</span>{ <span class="i">$TV</span>{<span class="i">$family</span>}{<span class="w">kids</span>} } <span class="s">)</span><span class="cm">,</span> <span class="q">&quot; kids named &quot;</span><span class="sc">;</span></li><li>         <a class="l_k" href="functions/print.html">print</a> <a class="l_k" href="functions/join.html">join</a> <span class="s">(</span><span class="q">&quot;, &quot;</span><span class="cm">,</span> <a class="l_k" href="functions/map.html">map</a> <span class="s">{</span> <span class="i">$_</span>-&gt;{<span class="w">name</span>} <span class="s">}</span> <span class="i">@</span>{ <span class="i">$TV</span>{<span class="i">$family</span>}{<span class="w">kids</span>} } <span class="s">)</span><span class="sc">;</span></li><li>         <a class="l_k" href="functions/print.html">print</a> <span class="q">&quot;\n&quot;</span><span class="sc">;</span></li><li>     <span class="s">}</span></li></ol></pre><a name="Database-Ties"></a><h1>Database Ties</h1>
<p>You cannot easily tie a multilevel data structure (such as a hash of
hashes) to a dbm file.  The first problem is that all but GDBM and
Berkeley DB have size limitations, but beyond that, you also have problems
with how references are to be represented on disk.  One experimental
module that does partially attempt to address this need is the MLDBM
module.  Check your nearest CPAN site as described in <a href="perlmodlib.html">perlmodlib</a> for
source code to MLDBM.</p>
<a name="SEE-ALSO"></a><h1>SEE ALSO</h1>
<p><a href="perlref.html">perlref</a>, <a href="perllol.html">perllol</a>, <a href="perldata.html">perldata</a>, <a href="perlobj.html">perlobj</a></p>
<a name="AUTHOR"></a><h1>AUTHOR</h1>
<p>Tom Christiansen &lt;<i>tchrist@perl.com</i>&gt;</p>




  <div id="page_index" class="hud_container">
    <div id="page_index_header" class="hud_header">
      <div id="page_index_close" class="hud_close"><a href="#" onClick="pageIndex.hide();return false;"></a></div>
      <div id="page_index_title" class="hud_title"><span class="hud_span_top">Page index</span></div>
      <div id="page_index_topright" class="hud_topright"></div>
    </div>
    <div id="page_index_content" class="hud_content">
      <ul><li><a href="#NAME">NAME
  </a><li><a href="#DESCRIPTION">DESCRIPTION</a><li><a href="#REFERENCES">REFERENCES
   </a><li><a href="#COMMON-MISTAKES">COMMON MISTAKES</a><li><a href="#CAVEAT-ON-PRECEDENCE">CAVEAT ON PRECEDENCE
 </a><li><a href="#WHY-YOU-SHOULD-ALWAYS-use-strict">WHY YOU SHOULD ALWAYS use strict</a><li><a href="#DEBUGGING">DEBUGGING
 
   
 
 </a><li><a href="#CODE-EXAMPLES">CODE EXAMPLES</a><li><a href="#ARRAYS-OF-ARRAYS">ARRAYS OF ARRAYS
 </a><ul><li><a href="#Declaration-of-an-ARRAY-OF-ARRAYS">Declaration of an ARRAY OF ARRAYS</a><li><a href="#Generation-of-an-ARRAY-OF-ARRAYS">Generation of an ARRAY OF ARRAYS</a><li><a href="#Access-and-Printing-of-an-ARRAY-OF-ARRAYS">Access and Printing of an ARRAY OF ARRAYS</a></ul><li><a href="#HASHES-OF-ARRAYS">HASHES OF ARRAYS
 </a><ul><li><a href="#Declaration-of-a-HASH-OF-ARRAYS">Declaration of a HASH OF ARRAYS</a><li><a href="#Generation-of-a-HASH-OF-ARRAYS">Generation of a HASH OF ARRAYS</a><li><a href="#Access-and-Printing-of-a-HASH-OF-ARRAYS">Access and Printing of a HASH OF ARRAYS</a></ul><li><a href="#ARRAYS-OF-HASHES">ARRAYS OF HASHES
 </a><ul><li><a href="#Declaration-of-an-ARRAY-OF-HASHES">Declaration of an ARRAY OF HASHES</a><li><a href="#Generation-of-an-ARRAY-OF-HASHES">Generation of an ARRAY OF HASHES</a><li><a href="#Access-and-Printing-of-an-ARRAY-OF-HASHES">Access and Printing of an ARRAY OF HASHES</a></ul><li><a href="#HASHES-OF-HASHES">HASHES OF HASHES
 </a><ul><li><a href="#Declaration-of-a-HASH-OF-HASHES">Declaration of a HASH OF HASHES</a><li><a href="#Generation-of-a-HASH-OF-HASHES">Generation of a HASH OF HASHES</a><li><a href="#Access-and-Printing-of-a-HASH-OF-HASHES">Access and Printing of a HASH OF HASHES</a></ul><li><a href="#MORE-ELABORATE-RECORDS">MORE ELABORATE RECORDS
  </a><ul><li><a href="#Declaration-of-MORE-ELABORATE-RECORDS">Declaration of MORE ELABORATE RECORDS</a><li><a href="#Declaration-of-a-HASH-OF-COMPLEX-RECORDS">Declaration of a HASH OF COMPLEX RECORDS</a><li><a href="#Generation-of-a-HASH-OF-COMPLEX-RECORDS">Generation of a HASH OF COMPLEX RECORDS</a></ul><li><a href="#Database-Ties">Database Ties</a><li><a href="#SEE-ALSO">SEE ALSO</a><li><a href="#AUTHOR">AUTHOR</a></ul>
    </div>
    <div id="page_index_footer" class="hud_footer">
      <div id="page_index_bottomleft" class="hud_bottomleft"></div>
      <div id="page_index_bottom" class="hud_bottom"><span class="hud_span_bottom"></span></div>
      <div id="page_index_resize" class="hud_resize"></div>
    </div>
  </div>


	    &nbsp;
          </div>
          <div id="content_footer">
          </div>
        </div>
        <div class="clear"></div>
      </div>
      
    <div id="footer">
      <div id="footer_content">
        <div id="footer_strapline">
          perldoc.perl.org - Official documentation for the Perl programming language
        </div>
        <div id="footer_links">
          <div id="address">
            <p class="name">Contact details</p>
            <p class="address">
	      Site maintained by <a href="mailto:jj@jonallen.info">Jon Allen (JJ)</a><br>
	    </p>
            <p class="contact">
              Documentation maintained by the <a href="http://lists.cpan.org/showlist.cgi?name=perl5-porters">Perl 5 Porters</a>
            </p>
          </div>
          <ul class="f1">
            <li>Manual
              <ul class="f2">
                <li><a href="index-overview.html">Overview</a>
                <li><a href="index-tutorials.html">Tutorials</a>
                <li><a href="index-faq.html">FAQs</a>
                <li><a href="index-history.html">Changes</a>
              </ul>
            <li>Reference
              <ul class="f2">
                <li><a href="index-language.html">Language</a>
                <li><a href="index-functions.html">Functions</a>
                <li><a href="perlop.html">Operators</a>
                <li><a href="perlvar.html">Variables</a>
              </ul>
            <li>Modules
              <ul class="f2">
                <li><a href="index-modules-A.html">Modules</a>
                <li><a href="index-pragmas.html">Pragmas</a>
                <li><a href="index-utilities.html">Utilities</a>
              </ul>
            <li>Misc
              <ul class="f2">
                <li><a href="index-licence.html">License</a>
                <li><a href="index-internals.html">Internals</a>
                <li><a href="index-platforms.html">Platforms</a>
              </ul>          </ul>
          <div class="clear"></div>
        </div>
      </div>
      <div id="footer_end">
      </div>
    </div>
      
    </div>
      <script language="JavaScript" type="text/javascript" src="static/exploreperl.js"></script>
      <script language="JavaScript" src="static/combined-20100403.js" type="text/javascript"></script>
<script language="JavaScript" type="text/javascript">
  perldoc.setPath(0);
  perldoc.pageName    = 'perldsc';
  perldoc.pageAddress = 'perldsc.html';
  perldoc.contentPage = 1;
  explorePerl.render();
  explorePerl.addEvents('explore_anchor');
</script>
    
  </body>
</html>