in reply to How do we remove specific HTML element
To understand how this works, I direct you to Flipin good, or a total flop?.use strict; use warnings; my $nav_seen =0; while (<DATA>) { # if inside of <nav> section, print it # unless we have seen a <nav> section before if (my $status = /<nav/ ... /<\/nav/) { print unless $nav_seen; $nav_seen++ if $status =~ /E/; } else {print} } =PRINTOUT <body> <nav a=b> <div> </div> </nav> <div> </div> </body> =cut __DATA__ <body> <nav a=b> <div> </div> </nav> <div> </div> <nav c=d> <li> </li> </nav> </body>
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: How do we remove specific HTML tag
by haukex (Archbishop) on Nov 07, 2021 at 05:36 UTC | |
by Marshall (Canon) on Nov 07, 2021 at 07:16 UTC | |
by Fletch (Bishop) on Nov 07, 2021 at 09:38 UTC | |
by Bod (Parson) on Nov 07, 2021 at 12:58 UTC | |
by marto (Cardinal) on Nov 07, 2021 at 13:55 UTC |