PERL
1. Write a Perl program to input one paragraph from the keyboard, with multiple sentences and words in it, and print those sentences in which at least one word has the same number of letters as the number of words in the sentence. For example, the sentence “Print this sentence” will not be printed, but the sentence “Print this short sentence” will be printed. The sentences should be printed with two words per line, unless it is the end of the sentence. E.g. If you type
This is a short paragraph. Longer ones are too boring. Are they not?
This would be printed as,
This is
a short
paragraph
Are they
Not
2. a. Write a Perl program that asks a user for a filename, then opens that file and replaces all occurrences of three letter words with TLW and all positive decimal numbers up to 50 only by their word equivalents. E.g. 25 as twenty five.
b. Write a Perl program that looks through /etc/passwd file, for names that occur in other person’s name and prints the full names of those people. Eg Shyam occurs in Shyamlal, so the full names of both Shyam and Shyamlal would be printed out.
3. a. Write a Perl regular expression to test whether a string looks like a valid NITC subject code of any class or branch.
b. Write a Perl program to input a file of “State city” lines given in alphabetical order by states only and produce a second file with lines in format "city belongs to state", ordered in alphabetical order of cities.
4. a. In the file protdom.dat (which will be given to you) is a list of proteins with their PFAM domains, like this
SwisProtID domain1 domain2 ...
. From this list you have to construct the opposite list, ie. a list of proteins that contains a certain domain, like this
Domain SwisProtID SwisProtID SwisProtID ....
Then save the list in domprot.dat. This goal can be achieved in various ways, you should do it by using hash of hashes.
Original content restored by GrandFather
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.