Home: Need a Custom or Prewritten Perl Program?: I need a program that...:
Split html file at keyword



Horace
New User

Sep 4, 2008, 10:00 AM


Views: 3546
Split html file at keyword

Hi,

I've got several 20MB+ html files that need splitting. They have contents like

fasdfsaf
asfd asdf

ENDSECTION

sdfgsdfg
dfre rert

ENDSECTION


What I want is to split these into pieces at the ENDSECTION point. Files would just be named sequentially. Can anyone help?

Thanks


(This post was edited by Horace on Sep 4, 2008, 10:01 AM)


KevinR
Veteran


Sep 4, 2008, 2:13 PM


Views: 3542
Re: [Horace] Split html file at keyword

run this and see if it splits the file correctly:


Code
open($html , "<" , 'path/to/file.html') or die "$!"; 
@sections = do {local $/ = 'ENDSECTION'; <$html>};
undef $html;
foreach my $section (@sections) {
print "\n-----begin section-----\n$section\n-----end section-----\n";
}

-------------------------------------------------