Need Perl inplace editing of files not on command line

后端 未结 3 590
小蘑菇
小蘑菇 2020-12-17 14:42

I have a program that has a number of filenames configured internally. The program edits a bunch of configuration files associated with a database account, and then changes

3条回答
  •  有刺的猬
    2020-12-17 15:38

    The recent versions of File::Slurp provide convenient functions, edit_file and edit_file_lines. The inner part of your code would look:

    use File::Slurp qw(edit_file);
    edit_file { s/$oldPass/$newPass/g } $filename;
    

提交回复
热议问题