Perl Exercises 2 ---------------- Write Perl one-liners for the following. If the "1-line" is getting too long, put the code into a script file. These exercises mostly use regexps to process text input. 1. A set of C files contain some old-style comments "/*...*/". Comments may be interspersed with C code on the same line. For any line that contains an old-style comment on the right end of the line, replace this by a new-style comment "//...". Multi-line comments and comments that are in the middle of a line should not be modified. 2. A set of C files contains new-style comments. Replace each new-style comment with a single-line old-style comment. 3. A set of C files contains multi-line comment blocks using old-style comments. Replace each comment block with a series of single-line new-style comments. 4. Count the number of lines of code (LOC) in a C file that uses "//" comments. 5. Write a simple macro processor in Perl. A macro of the form "four=two+two" causes every occurrence of the word "four" to be replaced by the string "two+two". The Perl script takes one or more macro definitions on the command-line, reads text from stdin and writes the processed output to stdout. * * * * *