maddfisherman has asked for the wisdom of the Perl Monks concerning the following question:
I want to separate the file into an array with the "****keywords****" as the break between elements how should i do this. So far this is what i did but it doesnt work why?<html> <head> <title>****TITLE****</title> <base href="http://south.com" /> <link rel="stylesheet" href="/stylesheets/css1.css" /> </head> <body> <table class="formatting"> <tbody> <tr> <td class="indexcell"> </td> <td class="maincell" id="top"> <h1 class="mainheading">****TITLE****</h1> ****STUFF**** <hr /> <p class="mainfooter"><a href="http://south.com/home.html#top" target= +"_top">south.com</a></p> <p class="mainfooter">Revised:</p> </td> </tr> </tbody> </table> </body> </html>
maybe i should use split or the $/ instead of regex??????open(TEMPLATE, "<template.html") || die $!; my @xtemplate; @xtemplate = <TEMPLATE>; close (TEMPLATE); my $xtemplate; $xtemplate = join("", @xtemplate); my @template; @template = $xtemplate =~ /^(.*?)\*{4}filename.ext\*{4}/s; push (@template, $xtemplate =~ /\*{4}filename.ext\*{4}(.*?)\*{4}title\ +*{4}/s); push (@template, $xtemplate =~ /\*{4}title\*{4}(.*?)\*{4}headings\*{4} +/s); push (@template, $xtemplate =~ /\*{4}headings\*{4}(.*?)/s);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: regex vs split
by Zaxo (Archbishop) on Aug 23, 2001 at 08:34 UTC | |
by pmas (Hermit) on Aug 23, 2001 at 18:04 UTC | |
|
Re: regex vs split
by jryan (Vicar) on Aug 23, 2001 at 07:51 UTC | |
by dragonchild (Archbishop) on Aug 23, 2001 at 17:25 UTC |