mdunnbass has asked for the wisdom of the Perl Monks concerning the following question:
So, I'm scrolling through an HTML page, and I'm trying to catch nested tags, i.e., a <span> followed by another <span> before the next </span>.
My question is, if I set up something like:
$i = 0; while ($html =~ m/</g) { # if the next character is the letter 's', $i++ # if the next character is the forward slash '/', $i-- # if $i = 1, $temp = everything from < to the next > # if $i > 1, do action to get rid of nested loop. }
$i = 0; while ($html =~ m/</g) { if ($_ =~ m/$1s/ {$i++;} if ($_ =~ m/$1\//) {$i--;} if ($i = 1) {$temp = everything from < to the next > } if ($i > 1) {do action to get rid of nested loop} }
Secondly, is this how you would do it? Is there a better way?
Thanks
Matt
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Brief question: m// and nested HTML tags
by fenLisesi (Priest) on Nov 28, 2006 at 15:27 UTC | |
|
Re: Brief question: m// and nested HTML tags
by andyford (Curate) on Nov 28, 2006 at 15:28 UTC | |
|
Re: Brief question: m// and nested HTML tags
by hardburn (Abbot) on Nov 28, 2006 at 15:28 UTC |