Perl Program 1: Paste
Write a Perl script [login to view URL] to implement the Unix paste command. Your script will not be given any options but it should assume the -s option has been specified. In other words your script should behave the same as paste -s.
Your script should match the behaviour of /usr/bin/paste exactly.
It can be tricky getting the white space right so dryrun tests 1-4 ignore white space but dryrun tests 5-8 check white space. If you are passing tests 1-4 and failing tests 5-8 you have the white space wrong.
For example:
%cat /home/cs2041/public_html/lab/perl/paste/file1
file1_line1
%cat /home/cs2041/public_html/lab/perl/paste/file2
file2_line1
file2_line2
%cat /home/cs2041/public_html/lab/perl/paste/file3
file3_line1
file3_line2
file3_line3
file3_line4
%cat /home/cs2041/public_html/lab/perl/paste/file4
file4_line1
file4_line2
%/usr/bin/paste -s /home/cs2041/public_html/lab/perl/paste/file?
file1_line1
file2_line1 file2_line2
file3_line1 file3_line2 file3_line3 file3_line4
file4_line1 file4_line2
%./[login to view URL] /home/cs2041/public_html/lab/perl/paste/file?
file1_line1
file2_line1 file2_line2
file3_line1 file3_line2 file3_line3 file3_line4
file4_line1 file4_line2
Your script must match the output of paste -s exactly (byte-for-byte identical).
%
For example:
%/usr/bin/paste -s /home/cs2041/public_html/lab/perl/paste/data? >output1
%./[login to view URL] /home/cs2041/public_html/lab/perl/paste/data? >output2
%diff output1 output2
Your next task is to automate the testing of [login to view URL] using diff.
You should write a short Shell script, [login to view URL], which runs a test like the one above, for example, it might produce output like this:
./[login to view URL] /home/cs2041/public_html/lab/perl/paste/data?
Running /usr/bin/paste -s /home/cs2041/public_html/lab/perl/paste/data1 /home/cs2041/public_html/lab/perl/paste/data2 /home/cs2041/public_html/lab/perl/paste/data3 /home/cs2041/public_html/lab/perl/paste/data4
Running ./[login to view URL] /home/cs2041/public_html/lab/perl/paste/data1 /home/cs2041/public_html/lab/perl/paste/data2 /home/cs2041/public_html/lab/perl/paste/data3 /home/cs2041/public_html/lab/perl/paste/data4
Running diff on the output
Test succeeded - output of ./[login to view URL] matched /usr/bin/paste
Perl Program 2: Prerequisites
Write a Perl script which prints courses which can be used to meet prerequisite requirements for a UNSW course. For example:
%[login to view URL] COMP2041
COMP1917
COMP1921
%[login to view URL] COMP9041
COMP9021
%[login to view URL] COMP9242
COMP3231
COMP3891
COMP9201
COMP9283
%[login to view URL] HESC3641
HESC2501
Your script must download the UNSW handbook web pages and extract the information from them when it is run.
You should print the courses in alphabetic order.
Hints
The UNSW handbook uses separate web pages for undergraduate and postgraduate handbook and you may need to extract prerequisites from either or both.
A simple way (but not the best way) to access a web page from Perl is like this:
%url = "[login to view URL]";
open F, "wget -q -O- $url|" or die;
while ($line = <F>) {
print $line;
}
You'll have to make some assumptions about the handbook pages.
It easy in Perl to skip lines until you find one specifying prerequisites.
It easy in Perl to remove part of a line.
It easy in Perl to remove HTML tags.
Hello,
I am the premier Perl scripting expert on these freelancing sites. I will design Perl scripts for these two tasks according to the specifications provided.
A milestone payment for the full budget for your project must be deposited with this site before your offer can be accepted.
Alan Idler
Chief Software Architect
Idleswell Software Creations
Hello. More 20 years programming experience.
I suggest to estimate whole job, not per hourly rate.
Regards.
-----------------------------------------------------------------------------------------------------------------------------------------------