Explore BrainMass

Perl scripts for file processing

Write separate Perl scripts for each of the given requirements. Mentioned input data files are attached with this posting. In each case command to run the script from the command line should look like:

COMMAND_PROMPT> input_data_file.txt

[1] A script that replaces each instance of "th" with "TH" in file part1.txt. The script should print the file to the screen, not just the replaced lines.

[2] A script to look for lines in the file part2.txt containing a period, question mark, or comma at the end of the line. When these lines are found, print only the part of the line that occurs after the word "it" (case insensitive).

[3] A script that prints only words (not the entire line) in the file part3.txt on a word boundary that have the letter "p" or "P" in them (i.e. words begin/end with P/p).


Solution Preview

You can implement the script in many ways. One such implementation of these three scripts is attached as You can use ...

Solution Summary

Please ensure that part2.txt is saved with Unix style newline ending, else the corresponding script will not give the expected output.