0
我似乎無法理解這些語法錯誤的原因。以下是我的代碼的一部分。我有嚴格的警告和警告。解密此語法錯誤
my $res = $s->scrape(URI->new($urlToScrape));
#warn Dump $res;
print "Show :".$res->{showtitle}[0];
my @sct;
if (defined {season}[0]) {
print $res->{season}[0];
@sct=split(' ', $res->{season}[0]);
} else {
my @spaa=split({showtitle}[0], {fulltitle}[0]);
print "Couldnt find season num at proper position\n";
print $spaa[0]."\n";
print $spaa[1]."\n";
exit;
}
我得到的錯誤是:
$ ./htmlscrape.pl
"my" variable @spaa masks earlier declaration in same scope at ./htmlscrape.pl line 43.
"my" variable @spaa masks earlier declaration in same scope at ./htmlscrape.pl line 44.
syntax error at ./htmlscrape.pl line 37, near "}["
syntax error at ./htmlscrape.pl line 40, near "}"
syntax error at ./htmlscrape.pl line 46, near "}"
Execution of ./htmlscrape.pl aborted due to compilation errors.
您需要發佈更多的代碼才能確定,但語法錯誤非常明顯:您已在其他位置聲明瞭「@ spaa」。 –
不應該定義$ res - > {season} [0]''定義{season} [0]'嗎? –
'{showtitle} [0],{fulltitle} [0]' – TLP