Perl脚本:从命令行vs脚本内部运行

时间:2013-05-09 20:35:04

标签: perl svn

从命令行运行时 - 它可以工作。

$ svn log http://svn.test.com/svn/trunk --stop-on-copy | perl -lne    'BEGIN{$/="-"x72; $re = shift} /$re/ and ($_)=split and print' JIRA-123456

r1
r2
r3

但是当我在脚本中运行时,我得到了这个错误:

$ perl svn_promote.pl

syntax error at -e line 2, near "="
BEGIN not safe after errors--compilation aborted at -e line 2.
svn: E720232: Write error: The pipe is being closed.

我正在尝试从svn评论中获取使用jira ticket提交的trunk的所有修订。该脚本将传递两个ARGS - URLJira ticket#

脚本:

$ cat svn_promote.pl
 #!/usr/bin/perl

 use strict;
 use warnings;

 my $svn_url=$ARGV[0];
 print "$svn_url\n";

 my $jira_ticket=$ARGV[1];
 print "$jira_ticket\n";

 my @revs = `svn log $svn_url --stop-on-copy | perl -lne 'BEGIN{$/="-"x72; $re = shift} /$re/ and ($_)=split and print' $jira_ticket`;
 chomp (@revs)
 print "$revs\n";

错误:

 $ perl svn_promote.pl
 Global symbol "$re" requires explicit package name at svn_promote.pl line 13.
 Global symbol "$re" requires explicit package name at svn_promote.pl line 13.
 syntax error at svn_promote.pl line 16, near ")

 print"
 Execution of svn_promote.pl aborted due to compilation errors.

0 个答案:

没有答案