Hi everyone, I'm just starting learning Perl. Work give me this exercise to do which I found a bit hard.I need to come back with answers tomorrow afternoon. So answers to any question will be great help please!!!
QUESTION1: Write a program to read in the following comma delimited data file into a data structure of A REFERENCE ARRAY OF HASHES, and performs each of the steps:
Member Number, First Name, Last Name, Subject, Score
-----------------------------------------------------
01,Newton,Issac,Physics,144.56
34,Einstein,Albert,Physics,12.22
78,Feynman,Richard,Physics,-17.34
11,Beethoven,Wolfgang,Music,11.78
89,Merx,Eddie,Cycling,319.01
a) Read in the records and write them out as 15 characters each with the first name in capitals.
b) Print out a sorted list of Surnames only.
c) Print all lines except those with member numbers 34 and 11.
d) Write a new file with the records in reverse order (i.e. print the last record first).
e) Write a new file with only rows where the score is greater than 100.
f) Read in file you made in question a) and write it out as tab delimited records.
QUESTION 2 There are two data files with contents as follows:
client.txt extracts.txt
(Member ID, Member Name) (Member ID)
------------------------------- -----------------
017,Billy Bloggs 024
024,Joe Cocker 099
099,Mozart 182
116,Oliver Bierhoff
182,Francois Mitterand
209,Lois Lane
a) Write code to print only those client details that have their key in extracts.txt.
Note that there are (at least) two main ways to do this.
b) Comment on how well your solution scales for files with hundreds of thousands of records (Hints: the extracts list should be much shorter than the whole clients list. How would you approach this question if both data files are huge?)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.