我有一个字符串如下:
$var = "ABC/type.xml/BYB?not=1234&at=6789&xyz&LMN";
Run Code Online (Sandbox Code Playgroud)
我想得到的不是和价值..如何与它一起工作?
你可以,而且也应该,使用能够正确地分析这个字符串,如适当的模块URI和URI::QueryParam:
use strict;
use warnings;
use URI;
use URI::QueryParam;
my $str = "ABC/type.xml/BYB?not=1234&at=6789&xyz&LMN";
my $url = URI->new($str);
my $not = $url->query_param('not');
my $at = $url->query_param('at');
print Dumper $not, $at;
Run Code Online (Sandbox Code Playgroud)
输出:
$VAR1 = '1234';
$VAR2 = '6789';
Run Code Online (Sandbox Code Playgroud)