Now I suspect that you're not asking about how to generate this form, but what to do with it after submission... as in how can you remove the actual posts from your file. You said that your file is separated by newlines. The easiet way - that I can see - to modify your file is to read it all in, change it and then write it out again. (just make sure that it won't ever be too huge). So... something like:
should do the trick nicely.$/ = ... # whatever my @posts = <FH>; # read all posts in at once and assign # each to an array element. my @keep_posts; for(my $index = 0; $index < @posts; $index++) { unless(defined($cgi->param("box$index")) { push @keep_posts, $posts[$index]; } } # open file... print all the kept ones out. print NEW_FILE join("\n\n\n", @keep_posts);
If this wasn't what you wanted, please ask again.
update After actually reading cLive ;-)'s post I feel silly for saying much the same thing. His way has the definate advantage of not needing to read the entire thing into memory, just handling it post by post. That's probably the better approach.
In reply to Re: Working on Deleting Sections of Text File Delimited by Newlines
by jarich
in thread Working on Deleting Sections of Text File Delimited by Newlines
by jerrygarciuh
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |