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: Perl Programming Help: Beginner: Sorting entry's in html file: Edit Log



ad65
Deleted

May 18, 2001, 9:33 AM


Views: 1901
Sorting entry's in html file

Hi, I need to know how to sort some lines in a html file into alphabetical order. In order to recognise which lines to sort, the lines begin with (<)!--mailto:--(>). After this is the names in a similar enclosure(hidden, I have to replace < and > with (<) and (>) or it doesn't show up in here), in which I want to sort by. The html file contains, for example this is an extract from the html file:

<P>
<table width=95% cellspacing=1 cellpadding=0 align=center bgcolor=#aa0000>
<tr>
<td align=center><font face=tahoma size=2 color=#dfdfdf><b>Codes</td>
<td align=center><font face=tahoma size=2 color=#dfdfdf><b>Author</td>
<td align=center><font face=tahoma size=2 color=#dfdfdf><b>Date</td>
</tr>
(<)!--Next Alpha Here:--(>)
(<)!--mailto:--(>)(<)!--Peter--(>)><TR><TD BGCOLOR=DFDFDF WIDTH=50%><FONT FACE=TAHOMA SIZE=2 COLOR=aa0000><A HREF="../news/New1.html">New1</A></FONT></TD><TD ALIGN=CENTER BGCOLOR=DFDFDF><FONT FACE=TAHOMA SIZE=2 COLOR=aa0000><A HREF="mailto:Peter@mydomain.com">Peter</A></FONT></TD><TD ALIGN=CENTER BGCOLOR=DFDFDF><FONT FACE=TAHOMA SIZE=2>May 18 2001</FONT></TD></TR>
(<)!--mailto:--(>)(<)!--Frank--(>)<TR><TD BGCOLOR=DFDFDF WIDTH=50%><FONT FACE=TAHOMA SIZE=2 COLOR=aa0000><A HREF="../news/New2.html">New2</A></FONT></TD><TD ALIGN=CENTER BGCOLOR=DFDFDF><FONT FACE=TAHOMA SIZE=2 COLOR=aa0000><A HREF="mailto:Frank@mydomain.com">Frank</A></FONT></TD><TD ALIGN=CENTER BGCOLOR=DFDFDF><FONT FACE=TAHOMA SIZE=2>May 18 2001</FONT></TD></TR>
(<)!--mailto:--(>)(<)!--Tim--(>)<TR><TD BGCOLOR=DFDFDF WIDTH=50%><FONT FACE=TAHOMA SIZE=2 COLOR=aa0000><A HREF="../news/New3.html">New3</A></FONT></TD><TD ALIGN=CENTER BGCOLOR=DFDFDF><FONT FACE=TAHOMA SIZE=2 COLOR=aa0000><A HREF="mailto:Tim@mydomain.com">Tim</A></FONT></TD><TD ALIGN=CENTER BGCOLOR=DFDFDF><FONT FACE=TAHOMA SIZE=2>May 18 2001</FONT></TD></TR>
(<)!--mailto:--(>)(<)!--Wayne--(>)<TR><TD BGCOLOR=DFDFDF WIDTH=50%><FONT FACE=TAHOMA SIZE=2 COLOR=aa0000><A HREF="../news/New4.html">New4</A></FONT></TD><TD ALIGN=CENTER BGCOLOR=DFDFDF><FONT FACE=TAHOMA SIZE=2 COLOR=aa0000><A HREF="mailto:Adam@mydomain.com">Adam</A></FONT></TD><TD ALIGN=CENTER BGCOLOR=DFDFDF><FONT FACE=TAHOMA SIZE=2>May 18 2001</FONT></TD></TR>
(<)!--mailto:--(>)(<)!--Adam--(>)<TR><TD BGCOLOR=DFDFDF WIDTH=50%><FONT FACE=TAHOMA SIZE=2 COLOR=aa0000><A HREF="../news/New5.html">New5</A></FONT></TD><TD ALIGN=CENTER BGCOLOR=DFDFDF><FONT FACE=TAHOMA SIZE=2 COLOR=aa0000><A HREF="mailto:Wayne@mydomain.com">Wayne</A></FONT></TD><TD ALIGN=CENTER BGCOLOR=DFDFDF><FONT FACE=TAHOMA SIZE=2>May 18 2001</FONT></TD></TR>
(<)!--mailto:--(>)(<)!--Fiona--(>)<TR><TD BGCOLOR=DFDFDF WIDTH=50%><FONT FACE=TAHOMA SIZE=2 COLOR=aa0000><A HREF="../news/New6.html">New6</A></FONT></TD><TD ALIGN=CENTER BGCOLOR=DFDFDF><FONT FACE=TAHOMA SIZE=2 COLOR=aa0000><A HREF="mailto:Fiona@mydomain.com">Fiona</A></FONT></TD><TD ALIGN=CENTER BGCOLOR=DFDFDF><FONT FACE=TAHOMA SIZE=2>May 18 2001</FONT></TD></TR>
(<)!--mailto:--(>)(<)!--Barbara--(>)<TR><TD BGCOLOR=DFDFDF WIDTH=50%><FONT FACE=TAHOMA SIZE=2 COLOR=aa0000><A HREF="../news/New7.html">New7</A></FONT></TD><TD ALIGN=CENTER BGCOLOR=DFDFDF><FONT FACE=TAHOMA SIZE=2 COLOR=aa0000><A HREF="mailto:Barbara@mydomain.com">Barbara</A></FONT></TD><TD ALIGN=CENTER BGCOLOR=DFDFDF><FONT FACE=TAHOMA SIZE=2>May 18 2001</FONT></TD></TR>
</table>

I'm writing something similar to a guestbook script, so the new entry's go in at the top there. Once this is done, I want to arrange them all in alphabetical order. As you can see, there are html lines that I don't want to change at all. Just the lines that start with (<)!--mailto:--(>) I want to sort in alphabetical order by what comes next inside (<)!-- --(>). This is probably a crap explanation, but if anyone knows how to do this then please help.

Sorry if the code is a bit messy, each line that starts(<)!--mailto:--(>) is supposed to be one whole line right down to the next mailto

(This post was edited by ad65 on May 18, 2001, 8:38 AM)


This post has not been edited


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

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