举例说明:
1. 标量:
匹配成功返回1,匹配失败返回0;
my $res = ($string=~/value='(\w+)'/);
print "$res\n";
output:
1
2. 列表:
use Data::Dumper;
my $string = "hello perl";
my @perls = $string =~ m/hello/ig ;
print Dumper @perls;
output:
$VAR1 = 'hello';
$string = "name='ns' value='CSDN'";
my ($res) = ($string=~/value='(\w+)'/);
print "$res\n";
output:
CSDN
3. 哈希:
$string = "name=xxyy leval=9 score=0";
%hash = {leval=>"12"};