logo

Regular Expression Loop in Perl

   

Added on  2019-09-16

2 Pages311 Words141 Views
 | 
 | 
 | 
Create aPerlprogram that is simply a loop over a set of "Regular Expressions" that perform the tasks described below. Use the attached fileSampleConfig.txtas input.Instructions:Using the attachedSampleConfig.txtfile, provide a Perl regular expression for each of thefollowing tasks:1.Remove any leading or trailing space from each line.2.Replace all of the occurrences of afull line of#characters (ignoring leading or training spaces and lines with just 1 #) with the following:# ---------- #3.Change any URL ending in.htmto end with.html4.For any set of multiple words following an equal sign (=), place what follows the equal sign in quotes.eg:a =bcdefgbecomesa = "bcdefg"eg:a =bcdremains a =bcdoAdd a semicolon (;) to theendof every line.oEvery line beginning with a comment marker (#) and containing additional text should have one (and only one) space following the comment marker.For example: # some text becomes....# some textoReplace any pattern in the form of[__UPPER-CASECHARACTERS__]with(lower-casecharacters)ie:Open square bracket + two underscores + upper-case text +two underscores +close square bracketeg:[__SOMEDATA__]becomes[somedata]oFollow every "configsection" with a comment that indicates the current section count:For example:[SVN] # Section: 1 [......] # Section: 2etc.Submit:1.A file containing thePerl codetofulfilltheaboverequirements
Regular Expression Loop in Perl_1

End of preview

Want to access all the pages? Upload your documents or become a member.