有人能告诉我一个例子,它展示了这两个变量的不同行为($^ N和$)?
解决方法
从
perldoc perlvar开始:
@H_502_18@$+: The text matched by the last bracket of the last successful
search pattern.
与
@H_502_18@$^N: The text matched by the used group most-recently closed (i.e.
the group with the rightmost closing parenthesis) of the last
successful search pattern.
这应该说明不同之处:
#!/usr/bin/perl use strict; use warnings; my $s = '12345'; if ( $s =~ /(1([0-9]))/ ) { print "$_\n" for $+,$^N; }
输出:
2 12