in reply to Delete multiple lines of text from a file?
perl -i.bak -ne 'print unless 16 .. 25' *.html
use XML::Twig; my $twig = XML::Twig->new( twig_handlers => { div => sub { my $class = $_->att("class") // ""; $_->delete if $class eq "topsearchbar"; }, } ); $twig->parse_html(\*DATA)->print; __END__ Each of the unwanted divs at this point <div>starts</div> with <div class="topsearchbar"> and <div>ends</div> with </div>. They are on lines 16-25 of the file.
<html><head></head><body>Each of the unwanted divs at this point <div>starts</div> with . They are on lines 16-25 of the file. </body></html>
|
|---|