我该如何解析。输入= {“ access_token”:“ Abcd45689012031”},输出=“ Abcd45689012031”
答案 0 :(得分:1)
看起来像JSON。因此,请使用JSON解析器:
#!/usr/bin/perl
use warnings;
use strict;
use JSON;
my $json = JSON->new;
my $object = $json->decode('{"access_token":"Abcd45689012031"}')
or die "JSON\n";
print $object->{access_token}, "\n";
exit 0;
试运行:
$ perl dummy.pl
Abcd45689012031
答案 1 :(得分:0)
使用JSON,JSON::XS甚至Cpanel::JSON::XS来解析JSON:
use JSON::XS qw{ decode_json };
my $input = '{"access_token":"Abcd45689012031"}';
my $json = decode_json($input);
my $token = $json->{access_token};