Perl Regular Expression Tasks

Verified

Added on  2019/09/16

|2
|311
|141
Practical Assignment
AI Summary
This assignment requires creating a Perl program that uses regular expressions to manipulate the content of a provided file, SampleConfig.txt. The tasks include removing leading/trailing spaces, replacing full-line '#' characters, changing .htm to .html in URLs, quoting multiple words after an equals sign, adding semicolons at the end of lines, standardizing comment formatting, converting uppercase patterns to lowercase, and adding section count comments. The submission includes the Perl code and the modified SampleConfig.txt file.
Document Page
Create a Perl program that is simply a loop over a set of "Regular Expressions" that perform the
tasks described below. Use the attached file SampleConfig.txt as input.
Instructions:
Using the attached SampleConfig.txt file, provide a Perl regular expression for each of the
following tasks:
1. Remove any leading or trailing space from each line.
2. Replace all of the occurrences of a full line of # characters (ignoring leading or training spaces
and lines with just 1 #) with the following: # ---------- #
3. Change any URL ending in .htm to end with .html
4. For any set of multiple words following an equal sign (=), place what follows the equal sign in
quotes.
o eg: a = bcd efg becomes a = "bcd efg"
o eg: a = bcd remains a = bcd
5. Add a semicolon (;) to the end of every line.
6. Every line beginning with a comment marker (#) and containing additional text should have one
(and only one) space following the comment marker.
o For example:
# some text becomes....
# some text
7. Replace any pattern in the form of [__UPPER-CASE CHARACTERS__] with (lower-
case characters)
o ie: Open square bracket + two underscores + upper-case text + two
underscores + close square bracket
o eg:[__SOMEDATA__] becomes [somedata]
8. Follow every "config section" with a comment that indicates the current section count:
o For example:
[SVN] # Section: 1
[......] # Section: 2
etc.
Submit:
1. A file containing the Perl code to fulfill the above requirements
2. A version of the SampleConfig.txt file incorporating all of the above
changes.
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
chevron_up_icon
1 out of 2
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]