【发布时间】:2011-06-05 09:19:36
【问题描述】:
嘿,我不确定为什么我的代码不起作用。我正在尝试从包含的 html 文件中提取一些信息。
Junk id="i_0100_1" alt="text1, text2 | text3"
Junk Junk id="i_0100_2" alt="text1, text2 | text3"
我就是用这个来做的。
my $file = "page.html";
open (LOGFILE, $file);
my %hash;
while (my $line = <LOGFILE>)
{
%hash = $line =~ /^\s*id="([^"]*)"\s*alt="([^"]*)"/mg;
print $hash{'id'};
}
close LOGFILE;
我错过了什么?
【问题讨论】:
标签: regex perl hash html-parsing