Many configuration files contain many comments, including commented- out default configuration directives. Write a program to remove these com- ments from a configuration file.
What will be an ideal response?
$ cat config-squish.pl
#!/usr/bin/perl
use warnings;
use strict;
while ( <> ) {
# Strip the trailing newline
chomp;
# Skip any lines that begin with a comment,
# potentially after leading whitespace
next if /^\s*#/;
# Strip any trailing whitespace
s/\s+$//;
# If there is at least one character left on
# the line, print it
print "$_\n" if /./;
}
You might also like to view...
MC What is a default constructor?
a) The first constructor defined in a class. b) A constructor with at least one default argument. c) A constructor that may be invoked with no arguments. d) None of the above.
What does it mean to set text “line for line”?
What will be an ideal response?
A StringBuilder object contains a memory block called a _____, which might or might not contain a string.
A. capacity B. buffer C. reference D. thread
Which of these PC cases has the largest footprint?
A. Laptop B. Desktop ATX case C. Small form factor case D. No significant differences between these footprints