I need help with a programming assignment

User Generated

FAF116084237375719397706

Programming

Description

Hello, I'm looking for help to do this lab, because I'm not that good at PERL programming language. I tried my best but nothing work. The submission is two hrs from now. can you help me do it please ?

LAB 5 - DESCRIPTION

Attached Files:

SampleConfig.txt 

perl example from the class.txt  ==>this is help to use it as a template please 

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.  

Note: Though this is a bit assignment is a bit contrived, it does represent the types of actual text manipulations that might be performed over many large files.

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) 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.
    • eg: a = bcd efg  becomes a = "bcd efg"
    • 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 folling the comment marker.
  7. Replace any pattern in the form of [__UPPER-CASE CHARACTERS__] with (lower-case characters)
    • ie: Open square bracket + two underscores + upper-case text + two underscores + close square bracket
    • eg:[__SOMEDATA__] becomes [somedata]
  8. Follow every "config section" with a comment that indicates the current section count:
    1. 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


This is an email from the professor could help :

I send this a just a word of caution about the regex101 site.  It turns out I was right the first time on LAB5-ex4:

  • For any set of multiple words following an equal sign (=),  place what follows the equal sign in quotes.
    • eg: a = bcd efg  becomes a = "bcd efg"
    • eg: a = bcd remains  a = bcd
The regular expression:  ^(.*)=\s*(.+\s+.+)$  does exactly the right thing by matching:
    1. The start of a line
    2. Any characters
    3. An equals sign
    4. Any spaces after the equals sign
    5. Group1
      1. One or more characters
      2. Followed by at least one white-space
      3. Followed by one or more characters.
    1. The end of a line.

However, the regex101 tester treats new-line characters (\n, \r, \f) as white-space characters, in "multi-line" mode.

To get around that issue you could define your own character class as just tabs and spaces like this:  ^(.*)=\s*(.+[ \t]+.+)$

In other words, it was a simple as I thought it should have been and If I had copied my original attempt to the Perl script, it probably would have worked fine. (When it initially failed in regex101 I thought I was going to have to use a positive lookahead, which gets a bit more advanced.)



User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer


Anonymous
This is great! Exactly what I wanted.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Related Tags