Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems 12th Asian Conference ACIIDS 2020 Phuket Thailand March 23 26 2020 Proceedings

Authors: Pawel Sitek ,Marcin Pietranik ,Marek Krotkiewicz ,Chutimet Srinilta

1st Edition

9811533792, 978-9811533792

More Books

Students also viewed these Databases questions

Question

Calculate the lifetime value (LTV) of a loyal customer.

Answered: 1 week ago

Question

Use service tiering to manage the customer base and build loyalty.

Answered: 1 week ago