Skip to content

Instantly share code, notes, and snippets.

@riywo
Created April 14, 2011 11:39
Show Gist options
  • Save riywo/919309 to your computer and use it in GitHub Desktop.
Save riywo/919309 to your computer and use it in GitHub Desktop.
設定ファイルをperlで書き換える
use strict;
use warnings;
use File::Copy;
open my $conf, '<', '/etc/my.cnf' or die;
open my $conf_new, '>', '/tmp/my.cnf' or die;
while (<$conf>) {
chomp;
my $line =
/innodb[_-]buffer[_-]pool[_-]size/ ? "aaaaaa" :
/innodb[_-]data[_-]file[_-]path/ ? "bbbb" :
...
$_;
print $conf_new "$line\n";
}
close $conf; close $conf_new;
File::Copy::move('/tmp/my.cnf', '/etc/my.cnf');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment