Due Date: September 25, 2000
(1) Write a Perl function deepListContents that accepts an array as input and return a string representing the deep content of the array. The array may contain only numbers, strings, or references to arrays. For example, running:
my @in = (1, 2, ["a", "b", [], [3, 4, [6]],
"c"], 45);
print "Original list:\n";
print deepListContents(@in);
will output:
Original list:
(1, 2, [a, b, [], [3, 4, [6]], c], 45)
(2) Write a Perl function reverseList that reverse the order of the elements of the input array in a deep manner. For example, running:
my @in = (1, 2, ["a", "b", [], [3, 4, [6]],
"c"], 45);
print "Original list:\n";
print deepListContents(@in);
print "\nReversed list:\n";
print deepListContents(reverseList(@in));
will output:
Original list:
(1, 2, [a, b, [], [3, 4, [6]], c], 45)
Reversed list:
(45, [c, [[6], 4, 3], [], b, a], 2, 1)
(3) Write a Perl program h3q3.pl that accepts an URL and list the domains of all links (a tags) in the URL contents, together with their numbers of occurrences. Your program needs only to handle relative URL and two protocols of absolute URL: http and mailto.
>h3q3.pl http://turquoise.rocks.uhcl.edu/yue/
For the page in the URL http://turquoise.rocks.uhcl.edu/yue/:
the following domains are accessed:
129.7.167.171: 2.
kona.uhcl.edu: 1.
nas.uhcl.edu: 4.
turquoise.rocks.uhcl.edu: 22.
www.christusrex.org: 1.
www.uhcl.edu: 2.
www.geneseo.edu: 1.
>h3q3.pl http://www.microsoft.com/
For the page in the URL http://www.microsoft.com/:
the following domains are accessed:
events.microsoft.com: 1.
msdn.microsoft.com: 2.
msn.com: 1.
on.linkexchange.com: 1.
shop.microsoft.com: 3.
www.microsoft.com: 37.
www.msn.com: 1.