yacoubean has asked for the wisdom of the Perl Monks concerning the following question:
I have a piece of code that's driving me crazy. In short, I am trying to extract the link from <a href links through out my HTML page. I have the extract_tagged code working in other parts of my program, and from what I can tell it is exactly the same as this chunk that is mis-behaving.
Bad boy:
if (/<a href\=\"/) { my @link = extract_tagged($_, '<a href="', '">', undef, undef); print " @link[4]\n"; }
This code works:
else { my @text = extract_tagged($_, '<li>', '</li>', undef, undef); print " *@text[4]*\n"; }
Here is some text that the code is parsing:
<li><a href="menuheader.html">menuheader.cfm</a></li>
I know that the condition for the if statement is firing, because I can print out some debugging text inside. If I return a count of @link, its 3, but it should at least be 5, if I understand things right. I've tried returning @link positions 0-5, and all return null. I've tried escaping the quotes and/or equal signs as well.
FYI, I am fairly new to Perl, so go easy on me. ;)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: extract_tagged
by ikegami (Patriarch) on Sep 29, 2004 at 15:24 UTC | |
by yacoubean (Scribe) on Sep 29, 2004 at 15:32 UTC | |
|
Re: extract_tagged
by mifflin (Curate) on Sep 29, 2004 at 15:30 UTC | |
|
Re: extract_tagged
by davido (Cardinal) on Sep 29, 2004 at 15:15 UTC | |
|
Re: extract_tagged
by JediWizard (Deacon) on Sep 29, 2004 at 15:16 UTC | |
|
Re: extract_tagged
by TedPride (Priest) on Sep 30, 2004 at 05:05 UTC |