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">
8 <LINK REL="stylesheet" HREF="book.css" TYPE="text/css">
14 <div id="header_enclosure">
21 <div align="center" id="page_header_title">Donna's Homework
29 <A id=next_link href="page-0102.html">Next</A>
33 <A id=index_link href="index.html">Index</A>
47 <div id="body_enclosure">
58 <div class="item_title"></div>
77 # This version imports the subs with explict args to use command
82 use NewArray1 qw( loadarr printarr);
84 my $data_file= "data.txt";
86 my $AofA = loadarr($data_file);
88 my ($aref, $hold) = printarr($AofA);
90 print "\nThe row with the largest number is: \n" ;
93 print "\nThe largest number is: \n" ;
96 print "\nProgram Complete: Array of Array's \n" ;
98 use NewHash1 qw( loadhash printhash);
100 my $hdata_file= "hdata.txt";
102 my $HofH = loadhash($hdata_file);
115 use vars '@EXPORT_OK';
117 @EXPORT_OK = qw( loadarr printarr );
123 open DAT, "$fh" || die "Could not open file! ($!)";
125 print "\nProgram Homework1: Array of Array's \n" ;
131 while (my $line = <DAT>) {
132 push @{$AofA}, [split(" ", $line)];
134 print "\nThe Array of Array's contains: \n" ;
135 print Dumper @{$AofA};
148 foreach my $Arr ( @{$AofA} ) {
149 foreach my $ele ( @{$Arr} ) {
150 if ($ele > $hold) {
157 return ($aref, $hold);
169 use vars '@EXPORT_OK';
171 @EXPORT_OK = qw( loadhash printhash );
177 open DAT, "$fh" || die "Could not open file! ($!)";
179 print "\nProgram Homework1: Two Level Hash \n\n" ;
187 while (my $line = <DAT>) {
188 ($team, $first, $last) = split(" ", $line);
189 $HofH->{$team}{$first} = $last;
192 print Dumper %{$HofH};
203 'stooge' => \&stooge,
204 'marx' => \&marx,
205 'more' => \&more,
208 foreach my $team_name (keys %{$HofH}) {
209 print "\nComedy Team: $team_name\n" ;
210 my $code_ref = $dispatch{ $team_name };
211 $code_ref or die "Can't find $team_name in dispatch table" ;
213 foreach my $first_name (sort keys %{ $HofH->{$team_name} } ) {
214 my $last_name = $HofH->{$team_name}->{$first_name} ;
215 print "\nFirst Name : $first_name \n" ;
216 $code_ref->($first_name);
222 print "Last Name : $HofH->{'stooge'}->{$nameref}\n";
227 print "Last Name : $HofH->{'marx'}->{$nameref}\n";
231 print Dumper "not found";
240 # This version imports the subs with an %EXPORT_TAGS tag
245 use NewArray2 qw( :Both);
247 my $data_file= "data.txt";
249 my $AofA = loadarr($data_file);
251 my ($aref, $hold) = printarr($AofA);
253 print "\nThe row with the largest number is: \n" ;
256 print "\nThe largest number is: \n" ;
259 print "\nProgram Complete: Array of Array's \n" ;
261 use NewHash2 qw( :Both);
263 my $hdata_file= "hdata.txt";
265 my $HofH = loadhash($hdata_file);
278 use vars qw '@EXPORT_OK %EXPORT_TAGS';
279 @EXPORT_OK = qw( loadarr printarr );
280 %EXPORT_TAGS = ( Both =>[qw(loadarr printarr)]);
286 open DAT, "$fh" || die "Could not open file! ($!)";
288 print "\nProgram Homework2: Array of Array's \n" ;
294 while (my $line = <DAT>) {
295 push @{$AofA}, [split(" ", $line)];
297 print "\nThe Array of Array's contains: \n" ;
298 print Dumper @{$AofA};
311 foreach my $Arr ( @{$AofA} ) {
312 foreach my $ele ( @{$Arr} ) {
313 if ($ele > $hold) {
320 return ($aref, $hold);
332 use vars qw '@EXPORT_OK %EXPORT_TAGS';
333 @EXPORT_OK = qw( loadhash printhash );
334 %EXPORT_TAGS = ( Both =>[qw(loadhash printhash)]);
340 open DAT, "$fh" || die "Could not open file! ($!)";
342 print "\nProgram Homework2: Two Level Hash \n\n" ;
350 while (my $line = <DAT>) {
351 ($team, $first, $last) = split(" ", $line);
352 $HofH->{$team}{$first} = $last;
355 print Dumper %{$HofH};
366 'stooge' => \&stooge,
367 'marx' => \&marx,
368 'more' => \&more,
371 foreach my $team_name (keys %{$HofH}) {
372 print "\nComedy Team: $team_name\n" ;
373 my $code_ref = $dispatch{ $team_name };
374 $code_ref or die "Can't find $team_name in dispatch table" ;
376 foreach my $first_name (sort keys %{ $HofH->{$team_name} } ) {
377 my $last_name = $HofH->{$team_name}->{$first_name} ;
378 print "\nFirst Name : $first_name \n" ;
379 $code_ref->($first_name);
385 print "Last Name : $HofH->{'stooge'}->{$nameref}\n";
390 print "Last Name : $HofH->{'marx'}->{$nameref}\n";
394 print Dumper "not found";
403 # This version will not import but will call the subs with Fully Qualified Names
410 my $data_file= "data.txt";
412 my $AofA = NewArray3::loadarr($data_file);
414 my ($aref, $hold) = NewArray3::printarr($AofA);
416 print "\nThe row with the largest number is: \n" ;
419 print "\nThe largest number is: \n" ;
422 print "\nProgram Complete: Array of Array's \n" ;
426 my $hdata_file= "hdata.txt";
428 my $HofH = NewHash3::loadhash($hdata_file);
430 NewHash3::printhash($HofH)
433 4. NewArray3.pm --- application/octet-stream; NewArray3.pm]...
444 open DAT, "$fh" || die "Could not open file! ($!)";
446 print "\nProgram Homework3: Array of Array's \n" ;
452 while (my $line = <DAT>) {
453 push @{$AofA}, [split(" ", $line)];
455 print "\nThe Array of Array's contains: \n" ;
456 print Dumper @{$AofA};
469 foreach my $Arr ( @{$AofA} ) {
470 foreach my $ele ( @{$Arr} ) {
471 if ($ele > $hold) {
478 return ($aref, $hold);
496 open DAT, "$fh" || die "Could not open file! ($!)";
498 print "\nProgram Homework3: Two Level Hash \n\n" ;
506 while (my $line = <DAT>) {
507 ($team, $first, $last) = split(" ", $line);
508 $HofH->{$team}{$first} = $last;
511 print Dumper %{$HofH};
522 'stooge' => \&stooge,
523 'marx' => \&marx,
524 'more' => \&more,
527 foreach my $team_name (keys %{$HofH}) {
528 print "\nComedy Team: $team_name\n" ;
529 my $code_ref = $dispatch{ $team_name };
530 $code_ref or die "Can't find $team_name in dispatch table" ;
532 foreach my $first_name (sort keys %{ $HofH->{$team_name} } ) {
533 my $last_name = $HofH->{$team_name}->{$first_name} ;
534 print "\nFirst Name : $first_name \n" ;
535 $code_ref->($first_name);
541 print "Last Name : $HofH->{'stooge'}->{$nameref}\n";
546 print "Last Name : $HofH->{'marx'}->{$nameref}\n";
550 print Dumper "not found";
569 <div id="footer_enclosure">
578 <A id=next_link href="page-0102.html">Next</A>
582 <A id=index_link href="index.html">Index</A>