ブログのRSSからトピックを取得するプログラムを作ったのですが、ダブルクォートのエスケープがうまくいっていないのか、エラーが発生します。
perl
1(中略) 2my $document = LWP::Simple::get($url) or die(); 3my $rss = XML::RSS->new; 4$rss->parse($document); 5for (@{$rss->{items}}){ 6 if($counter > 5){ 7 last; 8 } 9 10 my $date = substr($_->{pubDate}, 0, 10); 11 $date =~ s/\-./g; 12 $line .= "<li>" . $date; 13 $line .= " - "; 14 $line .= "<a href = \"" . $_->{link} . "\""; 15 $line .= $_->{title} . "</a></li>\n"; 16} 17$line .= "</ul>\n";
を実行すると、
Backslash found where operator expected at ./rss_meets.pl line 26, near "</li>\" (Missing operator before ?) String found where operator expected at ./rss_meets.pl line 28, near "$line .= "" (Might be a runaway multi-line "" string starting on line 26) (Missing semicolon on previous line?) String found where operator expected at ./rss_meets.pl line 30, near "open(BLOG, "" (Might be a runaway multi-line "" string starting on line 28) (Missing semicolon on previous line?) Having no space between pattern and following word is deprecated at ./rss_meets.pl line 30. String found where operator expected at ./rss_meets.pl line 30, at end of line (Missing semicolon on previous line?) syntax error at ./rss_meets.pl line 26, near "</li>\" Can't find string terminator '"' anywhere before EOF at ./rss_meets.pl line 30.
と怒られます。ダブルクォートの対応は気をつけたつもりですが、見落としはありますでしょうか?
![guest](/img/icon/icnUserSample.jpg)
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/06/06 03:06
2020/06/06 03:12
2020/06/06 03:15
2020/06/06 04:24