in reply to Re^2: regex basics
in thread regex basics
poj#!/usr/bin/env perl use strict; use warnings; my $iniprod = 'php.ini-production'; my $ininocm = 'php.ini-nocomments'; my $log = 'removed.log'; open my $IN, '<', $iniprod or die "Could not open $iniprod for reading: $!"; open my $LOG, '>', $log or die "Could not open $log for writing: $!"; my $count=0; my $text; while (<$IN>) { ++$count; if (/;\s+/) { print $LOG "$count : $_"; } else { $text .= $_; } } close $IN or die "Error closing $iniprod: $!"; # squash multiple blank lines to one $text =~ s{\n{3,}}{\n\n}gm; open my $OUT, '>', $ininocm or die "Could not open $ininocm for writing: $!"; print $OUT $text; close $OUT or die "Error closing $ininocm: $!"; __DATA__ line 1 ; this directive does such and such ; and some more ;some_directive line 2 line 3 line 4 line 5
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: regex basics
by jott19 (Initiate) on Feb 01, 2015 at 21:51 UTC |