我通过curl获得了一个变量$ response_code和一个网站的整个html代码。在这个字符串中,我想通过正则表达式搜索特定模式。但是,无论我搜索什么,我都无法比拟。当我在$ response_code中编写不同的东西时,它可以工作,数组是空的...... 这有什么不对吗?
use strict;
use warnings;
use WWW::Curl::Easy;
my $curl = WWW::Curl::Easy->new;
$curl->setopt(CURLOPT_HEADER,1);
$curl->setopt(CURLOPT_URL, 'https://fahrplaner.vbn.de/hafas/stboard.exe/dn?protocol=https:&input=8003760&boardType=dep&time=09$
# A filehandle, reference to a scalar or reference to a typeglob can be used here.
my $response_body;
$curl->setopt(CURLOPT_WRITEDATA,\$response_body);
# Starts the actual request
my $retcode = $curl->perform;
# Looking at the results...
if ($retcode == 0) {
# print("Transfer went ok\n");
my $response_code = $curl->getinfo(CURLINFO_HTTP_CODE);
# judge result and next action based on $response_code
# print("Received response: $response_body\n");
my @test = ($response_code =~ m/ontime/g);
print($test[0]);
}
else {
# Error code, type of error, error message
print("An error happened: $retcode ".$curl->strerror($retcode)." ".$curl->errbuf."\n");
}