Question: This is Perl Language. Please help me make this code work. #!/usr/bin/perl # Sports Team Year Owner Leader Coach 2nd Best Player # NE Patriots

This is Perl Language. Please help me make this code work.

#!/usr/bin/perl

# Sports Team Year Owner Leader Coach 2nd Best Player

# NE Patriots 2007 NFL Tom Brady Bill Belichick Randy Moss # Chicago Bulls 1991 NBA Michael Jordan Phil Jackson Scottie Pippen # NY Yankees 1998 MLB Derek Jeter Joe Torre Mariano Rivera # Edmonton Oilers 1983 NHL Wayne Gretzky Glen Sather Mark Messer # USA Basketball 1992 Olympics Magic Johnson Chuck Daly Michael Jordan

# I have created the following array:

@teams = ("New England Patriots", "Chicago Bulls", "New York Yankees", "Edmonton Oilers" , "USA Basketball");

# and the following Hash of Hashes:

%myTeams = ( "New England Patriots" => { yearBorn => 2007, owner => "NFL", leader => "Tom Brady", headCoach => "Bill Belichick" secondBestPlayer => "Randy Moss" }, "Chicago Bulls" => { yearBorn => 1991, owner => "NBA", leader => "Michael Jordan" headCoach => "Phil Jackson" secondBestPlayer => "Scottie Pippen" }, "New York Yankees" => { yearBorn => 1998, owner => "MLB", leader => "Derek Jeter" headCoach =>"Joe Torre" secondBestPlayer => "Mariano Rivera" }, "Edmonton Oilers" => { yearBorn => 1983, owner => "NHL", leader => "Wayne Gretzky", headCoach =>"Glen Sather" secondBestPlayer => "Mark Messer" }, "USA Basketball" => { yearBorn => 1992, owner => "Olympics", leader => "Magic Johnson" headCoach => "Chuck Daly" secondBestPlayer => "Michael Jordan" },

);

# To print out sorted Team information in the Hash of Hashes (ascending order):

print (" Best Sports Teams - sorted by Team Name ascending: ");

printf("%-20s \t%-6s \t%-10s \t%-25s \t%-25s \t%-25s ", "Team", "Year", "Owner", "Leader", "Coach", "2nd Best Player");

@sortedKeys = sort (@teams);

for $teamName (@sortedKeys) { $yearBorn = $myTeams{$teamName}{'yearBorn'}; $owner = $myTeams{$teamName}{'owner'}; $leader = $myTeams{$teamName}{'leader'}; $headCoach = $myTeams{$teamName}{'headCoach'}; $secondBestPlayer = $myTeams{$teamName}{'secondBestPlayer'}; printf("%-20s \t%-6i \t%-10s \t%-25s \t%-25s \t%25 ", $teamName, $yearBorn, $owner, $leader,$headCoach, $secondBestPlayer); print " "; }

# To print out sorted Team information in the Hash of Hashes (descending order):

print (" \Best Sports Teams - sorted by Team Name decending: ");

printf("%-20s \t%-6s \t%-10s \t%-25s ", "Team", "Year", "Owner", "Leader", "Coach", "2nd Best Player");

@reverseKeys = reverse (@sortedKeys);

for $teamName (@reverseKeys) { $yearBorn = $myTeams{$teamName}{'yearBorn'}; $owner = $myTeams{$teamName}{'owner'}; $leader = $myTeams{$teamName}{'leader'}; $headCoach = $myTeams{$teamName}{'headCoach'}; $secondBestPlayer = $myTeams{$teamName}{'secondBestPlayer'}; printf("%-20s \t%-6i \t%-10s \t%-25s ", $teamName, $yearBorn, $owner, $leader, $headCoach, $secondBestPlayer); print " "; }

print " HTML Page containing information on my Team: ";

print " "; print " "; print "Sports Teams"; print " "; print " "; print "

Best Sports Teams

"; print " "; print " ";

for $teamName (sort keys %myTeams ) { $yearBorn = $myTeams{$teamName}{'yearBorn'}; $owner = $myTeams{$teamName}{'owner'}; $leader = $myTeams{$teamName}{'leader'}; $headCoach = $myTeams{$teamName}{'headCoach'}; $secondBestPlayer = $myTeams{$teamName}{'secondBestPlayer'}; print "

"; } print "
TeamYearOwnerLeader
$teamName$yearBorn$owner$leader
"; print " "; print " ";

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!