Question: Assignment 8 - Perl I would like you to come up with a program that sets up 5 teams within a hash of hashes in

Assignment 8 - Perl

I would like you to come up with a program that sets up 5 teams within a hash of hashes in Perl. It would print three things:

A report showing the team name, year established, owner, and leader sorted in ascending order by team name

A report showing the same thing, but sorted in descending order by team name

HTML statements to display the team information within an HTML Table

Add at least two more attributes about your team, what other items could you add? Add them to all the areas of your output.

Loop and create a report that will output in XML just like you did with the HTML.

Remember to also add your two new challenge attributes to your XML output.

Template

# Perl Assignment # Teams using a Hash of Hashes # Superhero Team Year Owner Leader # Justice Society 1940 DC Hawkman # Justice League 1960 DC Superman # Fantastic Four 1961 Marvel Mr. Fantastic # Avengers 1963 Marvel Captain America # X-Men 1963 Marvel Professor X # I have created the following array: @teams = ("Justice Society", "Justice League", "Fantastic Four", "Avengers" , "X-Men"); # and the following Hash of Hashes: %myTeams = ( "Justice Society" => { yearBorn => 1940, owner => "DC", leader => "Hawkman", }, "Justice League" => { yearBorn => 1960, owner => "DC", leader => "Superman" }, "Fantastic Four" => { yearBorn => 1961, owner => "Marvel", leader => "Mr. Fantastic" }, "Avengers" => { yearBorn => 1963, owner => "Marvel", leader => "Captain America", }, "X-Men" => { yearBorn => 1963, owner => "Marvel", leader => "Professor X" }, ); # To print out sorted Team information in the Hash of Hashes (ascending order): print (" My Team - sorted by Team Name ascending: "); printf("%-20s \t%-6s \t%-10s \t%-25s ", "Team", "Year", "Owner", "Leader"); @sortedKeys = sort (@teams); for $teamName (@sortedKeys) { $yearBorn = $myTeams{$teamName}{'yearBorn'}; $owner = $myTeams{$teamName}{'owner'}; $leader = $myTeams{$teamName}{'leader'}; printf("%-20s \t%-6i \t%-10s \t%-25s ", $teamName, $yearBorn, $owner, $leader); print " "; } # To print out sorted Team information in the Hash of Hashes (descending order): print (" \My Team - sorted by Team Name decending: "); printf("%-20s \t%-6s \t%-10s \t%-25s ", "Team", "Year", "Owner", "Leader"); @reverseKeys = reverse (@sortedKeys); for $teamName (@reverseKeys) { $yearBorn = $myTeams{$teamName}{'yearBorn'}; $owner = $myTeams{$teamName}{'owner'}; $leader = $myTeams{$teamName}{'leader'}; printf("%-20s \t%-6i \t%-10s \t%-25s ", $teamName, $yearBorn, $owner, $leader); print " "; } print " HTML Page containing information on my Team: "; print " "; print " "; print "My Team"; print " "; print " "; print "

SuperHero Teams

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

print " XML file containing information on my Team - by Team Name ascending: ";

print " "; print " "; for $teamName (sort keys %myTeams ) { print " "; $yearBorn = $myTeams{$teamName}{'yearBorn'}; # do the same thing for owner # do the same thing for leader # do the same thing for the two other attributes print " "; print " $teamName "; # do the same thing for yearBorn # do the same thing for owner # do the same thing for leader # do the same thing for the two other attributes 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!