Created
March 8, 2012 18:22
-
-
Save run4flat/2002484 to your computer and use it in GitHub Desktop.
Quick line fixing with Perl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
open my $in_fh, '<', $file_name; | |
open my $out_fh, '>', "$file_name.new"; | |
while(<$in_fh>) { | |
# Current line is stored in $_ | |
# if current line contains the text 'zend-extensions'... | |
if ($_ =~ m/zend-extensions/) { | |
# ... comment it out | |
print $out_fh "; $_"; | |
} | |
else { | |
# otherwise, just pass the line unchanged | |
print $out_fh $_; | |
} | |
} | |
close $in_fh; | |
close $out_fh; | |
unlink $file_name; | |
rename "$file_name.new" => $file_name; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment