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: Re: Editing an nth match: Edit Log



ad65
Deleted

May 17, 2001, 6:46 PM


Views: 3790
Re: Editing an nth match

Yeah, I believe his code works too, the point being I think he got the wrong idea about what exactly i'm trying to do, which was my fault for not explaining well enough. Here's the code:

#
### THE FOLLOWING UPDATES THE INDEX PAGE WITH THE LATEST ENTRY
#

sub update_index {

open(MAIN, "$index_file") || die "Can't open MAIN: $index_file\n";
@main = <MAIN>;
close(MAIN);

open(MAIN, ">$index_file") || die "Can't open MAIN: $index_file\n";
foreach $line (@main) {
if ($line =~ /<TR><TD BGCOLOR=DFDFDF WIDTH=50%><FONT FACE=TAHOMA SIZE=2 COLOR=aa0000><A HREF=\"$filename\">$news</A></FONT></TD><TD ALIGN=CENTER BGCOLOR=DFDFDF><FONT FACE=TAHOMA SIZE=2 COLOR=aa0000><A HREF=\"mailto:$man\@soandsosite.com\">$man</A></FONT></TD><TD ALIGN=CENTER BGCOLOR=DFDFDF><FONT FACE=TAHOMA SIZE=2>$mon[$Month] $EntryDate</FONT></TD></TR>\n";
}

else {
print MAIN "$line";
}

}

close(MAIN);
&alphabet;

}

The rest goes on to create other pages and stuff, i'm not saying the script doesn't work, just I simply have no idea how to do what i've described in my other posts. Despite many attempts. And there's nothing wrong with the output of the page, I don't need to parse it, but thanx for the guess.

I don't think my previous post came out right, again, heres what I need to know how to do:

Open the file MAIN. Find all lines that begin with !--mailto:--. Match the 11th line that begins with !--mailto:--, IF there is one, and delete it. Ignore all the other lines, not changing any of them like. Close the file.

Alternatively if it's possible to delete all occurences after the 10th, of lines that begin with !--mailto-- then that would be fine too. Maybe this is too hard a question for a beginner's forum, come and have a go if you think ur ard enough. lol. No but really, please do help if you can!

(This post was edited by ad65 on May 17, 2001, 5:56 PM)


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