在 Perl 就地编辑中将备份文件保存到自定义目录 [英] save backup files to custom directory in Perl edit-in-place

查看:48
本文介绍了在 Perl 就地编辑中将备份文件保存到自定义目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经有一个 perl 文件 changes.pl.我可以通过 cmd 命令 运行 changes.pl.我正在寻找将备份文件保存到特定目录.我试过使用 cmd 命令 12.但是,我通过运行两者中的任何一个得到结果.

I've a perl file changes.pl already. I can run changes.pl via cmd command. I'm looking for saving backup files to a specific directory. I've tried using cmd command 1 and 2. But, I get result from running any of both.

changes.pl

BEGIN {
    @ARGV = map glob("\"$_\""), @ARGV;
}

s/a/b/g;
s/c/d/g;
s/e/f/g;

cmd 命令

perl -i.bak -p changes.pl My/Files/Directory/*.txt

cmd 命令 1

perl -i"save/*" -p changes.pl My/Files/Directory/*.txt

cmd 命令 2

perl -i.bak -i"save/*" -p changes.pl My/Files/Directory/*.txt

结果

无法对我的/文件/目录/文件 1.txt 进行就地文件存在.

Can't do inplace edit on My/Files/Directory/File 1.txt: File exists.

无法对我的/文件/目录/文件 2.txt 进行就地文件存在.

Can't do inplace edit on My/Files/Directory/File 2.txt: File exists.

无法对我的/文件/目录/文件 3.txt 进行就地文件存在.

Can't do inplace edit on My/Files/Directory/File 3.txt: File exists.

注意:

推荐答案

http://blogs.msdn.com/b/steverowe/archive/2008/11/26/using-perl-for-mass-in-place-编辑.aspx

tl;博士;尝试使用 for 循环而不是通配符.并且不要忘记%i"周围的引号,因为您的文件名中确实有空格.

tl;dr; Try using a for loop instead of a wildcard. And don't forget quotes around "%i" as you do have spaces in your filenames.

这篇关于在 Perl 就地编辑中将备份文件保存到自定义目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆