CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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

Post #1 of 2 (1722 views)
Split html file at keyword Can't Post

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

Post #2 of 2 (1718 views)
Re: [Horace] Split html file at keyword [In reply to] Can't Post

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";
}

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

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives