我是一个完整的perl新手,使用perl 5.10运行perl脚本并收到此警告:
$* is no longer supported at migrate.pl line 380.
Run Code Online (Sandbox Code Playgroud)
任何人都可以描述$*做了什么以及现在建议更换它的是什么?或者,如果您可以向我指出描述这一点的文档会很棒.
我正在运行的脚本是将源代码数据库从vss迁移到svn,可以在这里找到:http: //www.x2systems.com/files/migrate.pl.txt
使用它的两段代码是:
$* = 1;
$/ = ':';
$cmd = $SSCMD . " Dir -I- \"$proj\"";
$_ = `$cmd`;
# what this next expression does is to merge wrapped lines like:
# $/DeviceAuthority/src/com/eclyptic/networkdevicedomain/deviceinterrogator/excep
# tion:
# into:
# $/DeviceAuthority/src/com/eclyptic/networkdevicedomain/deviceinterrogator/exception:
s/\n((\w*\-*\.*\w*\/*)+\:)/$1/g;
$* = 0;
Run Code Online (Sandbox Code Playgroud)
然后在某些方面:
$cmd = $SSCMD . " get -GTM -W -I-Y -GL\"$localdir\" -V$version \"$file\" 2>&1";
$out = `$cmd`;
# get rid of stupid VSS warning messages
$* = 1;
$out =~ s/\n?Project.*rebuilt\.//g;
$out =~ s/\n?File.*rebuilt\.//g;
$out =~ s/\n.*was moved out of this project.*rebuilt\.//g;
$out =~ s/\nContinue anyway.*Y//g;
$* = 0;
Run Code Online (Sandbox Code Playgroud)
非常感谢,
Axe*_*man 12
来自perlvar:
在现代Perl中不推荐使用$*,在模式匹配上由/ s和/ m修饰符取代.
如果您可以访问匹配的位置,只需将其添加到结尾:
$haystack =~ m/.../sm;
Run Code Online (Sandbox Code Playgroud)
如果您只能访问该字符串,则可以使用表达式包围表达式
qr/(?ms-ix:$expr)/;
Run Code Online (Sandbox Code Playgroud)
或者在你的情况下:
s/\n((\w*\-*\.*\w*\/*)+\:)/$1/gsm;
Run Code Online (Sandbox Code Playgroud)