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 "SuperHero Teams
"; print "Team | Year | Owner | Leader |
---|---|---|---|
$teamName | $yearBorn | $owner | $leader |
print " XML file containing information on my Team - by Team Name ascending: ";
print " "; print "
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started