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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|