On Thu, Jul 14, 2016 at 10:50 AM, Darryl Philip Baker <
[email protected]> wrote:
> While not truly a beginner it feels that way after not doing anything
> substantial in Perl in many years.
>
> I currently need a program to take Apache HTTPD configuration files in
> HTTPD 2.2 syntax used in current production and convert them to HTTPD 2.4
> syntax in future production. I will need to do this many times weekly until
> we cut over to the new systems. My first challenge is converting the
> permissions syntax:
> Order deny,allow
> Deny from all
> To
> Require all denied
>
Why not go line by line? Not 100% certain on the Apache syntax, but in your
while loop where you are processing line by line:
next if /Order\s+deny,\s*allow/i; # Skip it in the output
if( /(\s*)Deny\s+from\s+all/i) {
my $leading_whitespace = $1; # Preserve whatever whitespace is in the
file now, could be multiple tabs and or spaces
print $leading_whitespace . "Require all denied";
}