两个分支之间的非集成变更列表
当我在命令行中使用以下命令时,它会给出非集成更改列表的列表。
p4 interchanges -t $branch1 @$date1, @$date2 $branch2 > changes.txt
但是,当我在 Perl 脚本中使用此命令时,如下所示,它不会给出输出:
$cmd = system ("p4 interchanges -t $branch1 @$date1, @$date2 $branch2 > changes.txt");
命令行中的输出消息是一些错误,如下所示:
branch1, - all revision(s) already integrated.
问题是因为 date1 和 date2 之间使用了逗号?如何在 Perl 脚本中使用此命令?
when I use the following command in command line it's giving list of non integrated change lists.
p4 interchanges -t $branch1 @$date1, @$date2 $branch2 > changes.txt
But when I use this command in a Perl script as below it's not giving output:
$cmd = system ("p4 interchanges -t $branch1 @$date1, @$date2 $branch2 > changes.txt");
The output message in commandline is some error as given below:
branch1, - all revision(s) already integrated.
The issue is because of the comma used between date1 and date2? How to use this command in a Perl script?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您要使用 Perl 进行大量 Perforce 操作,请尝试 P4Perl,它将 Perforce 包装在 Perl 原生 API 中。
从文档中抄袭,您的
system()
调用可以实现为:$c
将包含每个未集成变更列表的数组引用。If you're going to be doing a lot of Perforce with Perl, try the P4Perl, which wraps Perforce in a Perl-native API.
Cribbing from the documentation, your
system()
call could be implemented as:$c
will contain an array reference with each of the unintegrated changelists.这就是为什么打开
strict
如此重要的原因警告
编译指示。字符串“@$date1”的含义并不像您想象的那样。它试图将$data1
作为数组取消引用。因为strict
不在,所以它会将$date1
的内容视为符号引用。如果您打开了strict
,您会看到如下错误消息:您可能应该这样说:
如果您期望
$branch1
,,您也可能会遇到问题>$date1
等是 shell 变量而不是 Perl 变量。在这种情况下你应该说:This is why it is so important to turn on the
strict
andwarnings
pragmas. The string "@$date1" does not mean what you think it does. It is trying to dereference$data1
as a an array. Becausestrict
isn't on it is treating the contents of$date1
as a symbolic reference. If you had turned onstrict
you would have seen an error message like:You should probably say this instead:
You may also have a problem if you expect
$branch1
,$date1
, etc. to be shell variables instead of Perl variables. In that case you should say: