Skip to content

Instantly share code, notes, and snippets.

@run4flat
Created March 8, 2012 18:22
Show Gist options
  • Save run4flat/2002484 to your computer and use it in GitHub Desktop.
Save run4flat/2002484 to your computer and use it in GitHub Desktop.
Quick line fixing with Perl
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