initial commit
[urisagit/CMS-Simple.git] / make_slides / output / page-0101.html
1 <?xml version="1.0" encoding="utf-8"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"
3         "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">
4 <HTML xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
5 <HEAD>
6
7 <TITLE></TITLE>
8 <LINK REL="stylesheet" HREF="book.css" TYPE="text/css">
9
10 </HEAD>
11
12
13 <BODY id="" >
14         <div id="header_enclosure">
15
16                 
17         
18
19                 
20                 <H1>
21                 <div align="center" id="page_header_title">Donna's Homework
22 </div>
23                 </H1>
24                 
25
26         
27
28         
29                 <A id=next_link href="page-0102.html">Next</A>
30         
31
32         
33                 <A id=index_link href="index.html">Index</A>
34         
35
36         
37
38
39         
40
41 <HR>
42
43         
44
45         </div>
46
47         <div id="body_enclosure">
48
49                 
50         
51
52         <UL>
53
54         
55                 <div class="item">
56                 <LI>
57                 
58                         <div class="item_title"></div>
59                 
60
61                 
62
63                 
64
65                 
66
67
68                 
69                         <div class="code">
70                                 <font size=+1><PRE>
71
72
73 # 3. CallMain1.pl
74
75 package CallMain1;
76
77 # This version imports the subs with explict args to use command 
78
79 use strict;
80 use Data::Dumper;
81
82 use NewArray1 qw( loadarr printarr);
83
84 my $data_file= &quot;data.txt&quot;;
85         
86 my $AofA = loadarr($data_file);
87
88 my ($aref, $hold) = printarr($AofA);    
89
90 print &quot;\nThe row with the largest number is: \n&quot; ;
91 print Dumper $aref;
92         
93 print &quot;\nThe largest number is: \n&quot; ; 
94 print Dumper $hold;             
95         
96 print &quot;\nProgram Complete:  Array of Array's \n&quot; ;            
97
98 use NewHash1 qw( loadhash printhash);
99
100 my $hdata_file= &quot;hdata.txt&quot;;
101         
102 my $HofH = loadhash($hdata_file);
103
104 printhash($HofH);       
105
106
107 # 4. NewArray1.pm
108
109 package NewArray1;
110
111 use strict;
112 use Data::Dumper;
113
114 use base 'Exporter';
115 use vars '@EXPORT_OK';
116
117 @EXPORT_OK = qw( loadarr printarr );
118
119 sub loadarr {
120         
121         my ($fh) = @_;
122                 
123         open DAT, &quot;$fh&quot; || die &quot;Could not open file! ($!)&quot;;
124
125         print &quot;\nProgram Homework1:  Array of Array's \n&quot; ;           
126         
127         my $AofA ;
128         my $hold = 0;
129         my $aref;
130         
131         while (my $line = &lt;DAT&gt;) {  
132                 push @{$AofA},  [split(&quot; &quot;, $line)];
133         }
134         print &quot;\nThe Array of Array's contains: \n&quot; ;         
135         print Dumper @{$AofA}; 
136
137         return ($AofA);         
138 }
139
140 sub printarr {
141         
142         my $hold;
143         my $ele;
144         my $aref;
145         
146         my ($AofA) = @_;
147         
148         foreach my $Arr ( @{$AofA}  ) { 
149                 foreach my $ele ( @{$Arr} ) {
150                                 if ($ele &gt; $hold) {
151                                         $aref = $Arr;
152                                         $hold = $ele;
153                         }               
154                 }
155         }
156         
157         return ($aref, $hold);          
158
159 }
160
161 # 5. NewHash1.pm
162
163 package NewHash1;
164
165 use strict;
166 use Data::Dumper;
167
168 use base 'Exporter';
169 use vars '@EXPORT_OK';
170
171 @EXPORT_OK = qw( loadhash printhash );
172
173 sub loadhash {
174         
175 my ($fh) = @_;
176                 
177 open DAT, &quot;$fh&quot; || die &quot;Could not open file! ($!)&quot;;
178
179 print &quot;\nProgram Homework1:  Two Level Hash \n\n&quot; ;   
180
181 my $HofH;
182
183 my $team;
184 my $last;
185 my $first;
186
187         while (my $line = &lt;DAT&gt;) { 
188          ($team, $first, $last) = split(&quot; &quot;, $line);          
189           $HofH-&gt;{$team}{$first} = $last;     
190         } 
191         
192         print Dumper %{$HofH}; 
193         
194         return ($HofH);         
195         
196 }
197
198 sub printhash {
199  
200  my ($HofH) = @_;
201  
202         my %dispatch = (
203                 'stooge'        =&gt; \&amp;stooge,
204                 'marx'  =&gt; \&amp;marx,
205                 'more'  =&gt; \&amp;more,
206         );
207
208         foreach my $team_name (keys %{$HofH})  {                                                                                                
209                 print &quot;\nComedy Team: $team_name\n&quot; ;                         
210                 my $code_ref = $dispatch{ $team_name };         
211                 $code_ref or die &quot;Can't find $team_name in dispatch table&quot; ;
212                                 
213                 foreach my $first_name  (sort keys %{ $HofH-&gt;{$team_name} } ) {      
214                         my $last_name  = $HofH-&gt;{$team_name}-&gt;{$first_name} ;             
215                         print &quot;\nFirst Name : $first_name \n&quot; ;
216                         $code_ref-&gt;($first_name);    
217                 }
218         }               
219
220         sub stooge {
221                 my $nameref = shift;
222                 print &quot;Last Name  : $HofH-&gt;{'stooge'}-&gt;{$nameref}\n&quot;;
223                 }
224         
225         sub marx {
226                 my $nameref = shift;
227                 print &quot;Last Name  : $HofH-&gt;{'marx'}-&gt;{$nameref}\n&quot;;     
228         }
229         
230         sub more {
231                 print Dumper &quot;not found&quot;;
232         }
233
234 }
235
236 # 3. CallMain2.pl
237
238 package CallArray2;
239
240 # This version imports the subs with an %EXPORT_TAGS tag 
241
242 use strict;
243 use Data::Dumper;
244
245 use NewArray2 qw( :Both);
246
247 my $data_file= &quot;data.txt&quot;;
248         
249 my $AofA = loadarr($data_file);
250
251 my ($aref, $hold) = printarr($AofA);    
252
253 print &quot;\nThe row with the largest number is: \n&quot; ;
254 print Dumper $aref;
255         
256 print &quot;\nThe largest number is: \n&quot; ; 
257 print Dumper $hold;             
258         
259 print &quot;\nProgram Complete:  Array of Array's \n&quot; ;            
260
261 use NewHash2 qw( :Both);
262
263 my $hdata_file= &quot;hdata.txt&quot;;
264         
265 my $HofH = loadhash($hdata_file);
266
267 printhash($HofH);       
268
269
270 # 4. NewArray2.pm
271
272 package NewArray2;
273
274 use strict;
275 use Data::Dumper;
276
277 use base 'Exporter';
278 use vars qw '@EXPORT_OK %EXPORT_TAGS';
279 @EXPORT_OK = qw( loadarr printarr );
280 %EXPORT_TAGS = ( Both =&gt;[qw(loadarr printarr)]);
281
282 sub loadarr {
283         
284         my ($fh) = @_;
285                 
286         open DAT, &quot;$fh&quot; || die &quot;Could not open file! ($!)&quot;;
287
288         print &quot;\nProgram Homework2:  Array of Array's \n&quot; ;           
289         
290         my $AofA ;
291         my $hold = 0;
292         my $aref;
293         
294         while (my $line = &lt;DAT&gt;) {  
295                 push @{$AofA},  [split(&quot; &quot;, $line)];
296         }
297         print &quot;\nThe Array of Array's contains: \n&quot; ;         
298         print Dumper @{$AofA}; 
299
300         return ($AofA);         
301 }
302
303 sub printarr {
304         
305         my $hold;
306         my $ele;
307         my $aref;
308         
309         my ($AofA) = @_;
310         
311         foreach my $Arr ( @{$AofA}  ) { 
312                 foreach my $ele ( @{$Arr} ) {
313                                 if ($ele &gt; $hold) {
314                                         $aref = $Arr;
315                                         $hold = $ele;
316                         }               
317                 }
318         }
319         
320         return ($aref, $hold);          
321
322 }
323
324 # 5. NewHash2.pm
325
326 package NewHash2;
327
328 use strict;
329 use Data::Dumper;
330
331 use base 'Exporter';
332 use vars qw '@EXPORT_OK %EXPORT_TAGS';
333 @EXPORT_OK = qw( loadhash printhash );
334 %EXPORT_TAGS = ( Both =&gt;[qw(loadhash printhash)]);
335
336 sub loadhash {
337         
338 my ($fh) = @_;
339                 
340 open DAT, &quot;$fh&quot; || die &quot;Could not open file! ($!)&quot;;
341
342 print &quot;\nProgram Homework2:  Two Level Hash \n\n&quot; ;   
343
344 my $HofH;
345
346 my $team;
347 my $last;
348 my $first;
349
350         while (my $line = &lt;DAT&gt;) { 
351          ($team, $first, $last) = split(&quot; &quot;, $line);          
352           $HofH-&gt;{$team}{$first} = $last;     
353         } 
354         
355         print Dumper %{$HofH}; 
356         
357         return ($HofH);         
358         
359 }
360
361 sub printhash {
362  
363  my ($HofH) = @_;
364  
365         my %dispatch = (
366                 'stooge'        =&gt; \&amp;stooge,
367                 'marx'  =&gt; \&amp;marx,
368                 'more'  =&gt; \&amp;more,
369         );
370
371         foreach my $team_name (keys %{$HofH})  {                                                                                                
372                 print &quot;\nComedy Team: $team_name\n&quot; ;                         
373                 my $code_ref = $dispatch{ $team_name };         
374                 $code_ref or die &quot;Can't find $team_name in dispatch table&quot; ;
375                                 
376                 foreach my $first_name  (sort keys %{ $HofH-&gt;{$team_name} } ) {      
377                         my $last_name  = $HofH-&gt;{$team_name}-&gt;{$first_name} ;             
378                         print &quot;\nFirst Name : $first_name \n&quot; ;
379                         $code_ref-&gt;($first_name);    
380                 }
381         }               
382
383         sub stooge {
384                 my $nameref = shift;
385                 print &quot;Last Name  : $HofH-&gt;{'stooge'}-&gt;{$nameref}\n&quot;;
386                 }
387         
388         sub marx {
389                 my $nameref = shift;
390                 print &quot;Last Name  : $HofH-&gt;{'marx'}-&gt;{$nameref}\n&quot;;     
391         }
392         
393         sub more {
394                 print Dumper &quot;not found&quot;;
395         }
396
397 }
398
399 # 3. CallMain3.pl
400
401 package CallArray3;
402
403 # This version will not import but will call the subs with Fully Qualified Names 
404
405 use strict;
406 use Data::Dumper;
407
408 use NewArray3;
409
410 my $data_file= &quot;data.txt&quot;;
411         
412 my $AofA = NewArray3::loadarr($data_file);
413
414 my ($aref, $hold) = NewArray3::printarr($AofA); 
415
416 print &quot;\nThe row with the largest number is: \n&quot; ;
417 print Dumper $aref;
418         
419 print &quot;\nThe largest number is: \n&quot; ; 
420 print Dumper $hold;             
421         
422 print &quot;\nProgram Complete:  Array of Array's \n&quot; ;            
423
424 use NewHash3;
425
426 my $hdata_file= &quot;hdata.txt&quot;;
427         
428 my $HofH = NewHash3::loadhash($hdata_file);
429
430 NewHash3::printhash($HofH)
431
432
433 4. NewArray3.pm --- application/octet-stream; NewArray3.pm]...
434
435 package NewArray3;
436
437 use strict;
438 use Data::Dumper;
439
440 sub loadarr {
441         
442         my ($fh) = @_;
443                 
444         open DAT, &quot;$fh&quot; || die &quot;Could not open file! ($!)&quot;;
445
446         print &quot;\nProgram Homework3:  Array of Array's \n&quot; ;           
447         
448         my $AofA ;
449         my $hold = 0;
450         my $aref;
451         
452         while (my $line = &lt;DAT&gt;) {  
453                 push @{$AofA},  [split(&quot; &quot;, $line)];
454         }
455         print &quot;\nThe Array of Array's contains: \n&quot; ;         
456         print Dumper @{$AofA}; 
457
458         return ($AofA);         
459 }
460
461 sub printarr {
462         
463         my $hold;
464         my $ele;
465         my $aref;
466         
467         my ($AofA) = @_;
468         
469         foreach my $Arr ( @{$AofA}  ) { 
470                 foreach my $ele ( @{$Arr} ) {
471                                 if ($ele &gt; $hold) {
472                                         $aref = $Arr;
473                                         $hold = $ele;
474                         }               
475                 }
476         }
477         
478         return ($aref, $hold);          
479
480 }
481
482 return ('TRUE');
483
484
485 # 5. NewHash3.pm
486
487 package NewHash3;
488
489 use strict;
490 use Data::Dumper;
491
492 sub loadhash {
493         
494 my ($fh) = @_;
495                 
496 open DAT, &quot;$fh&quot; || die &quot;Could not open file! ($!)&quot;;
497
498 print &quot;\nProgram Homework3:  Two Level Hash \n\n&quot; ;   
499
500 my $HofH;
501
502 my $team;
503 my $last;
504 my $first;
505
506         while (my $line = &lt;DAT&gt;) { 
507          ($team, $first, $last) = split(&quot; &quot;, $line);          
508           $HofH-&gt;{$team}{$first} = $last;     
509         } 
510         
511         print Dumper %{$HofH}; 
512         
513         return ($HofH);         
514         
515 }
516
517 sub printhash {
518  
519  my ($HofH) = @_;
520  
521         my %dispatch = (
522                 'stooge'        =&gt; \&amp;stooge,
523                 'marx'  =&gt; \&amp;marx,
524                 'more'  =&gt; \&amp;more,
525         );
526
527         foreach my $team_name (keys %{$HofH})  {                                                                                                
528                 print &quot;\nComedy Team: $team_name\n&quot; ;                         
529                 my $code_ref = $dispatch{ $team_name };         
530                 $code_ref or die &quot;Can't find $team_name in dispatch table&quot; ;
531                                 
532                 foreach my $first_name  (sort keys %{ $HofH-&gt;{$team_name} } ) {      
533                         my $last_name  = $HofH-&gt;{$team_name}-&gt;{$first_name} ;             
534                         print &quot;\nFirst Name : $first_name \n&quot; ;
535                         $code_ref-&gt;($first_name);    
536                 }
537         }               
538
539         sub stooge {
540                 my $nameref = shift;
541                 print &quot;Last Name  : $HofH-&gt;{'stooge'}-&gt;{$nameref}\n&quot;;
542                 }
543         
544         sub marx {
545                 my $nameref = shift;
546                 print &quot;Last Name  : $HofH-&gt;{'marx'}-&gt;{$nameref}\n&quot;;     
547         }
548         
549         sub more {
550                 print Dumper &quot;not found&quot;;
551         }
552
553 }
554 return ('TRUE');
555 </PRE></font>
556                         </div>
557                 
558
559                 </LI>
560                 </div>
561         
562
563         </UL>
564
565
566
567         </div>
568
569         <div id="footer_enclosure">
570                 
571
572         
573 <HR>
574
575         
576
577         
578                 <A id=next_link href="page-0102.html">Next</A>
579         
580
581         
582                 <A id=index_link href="index.html">Index</A>
583         
584
585         
586
587
588         
589
590         
591
592
593
594         </div>
595 </BODY>
596
597 </HTML>
598