I agree that you should either use the CGI module or not use it but not include it and then ignore it. I was going to say something along the lines of you should name all of your checkboxes the same and then just cycle through the values, but when I considered the code snippet below, that didn't work as well.... but often you should do that.

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:

$/ = ... # 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);
should do the trick nicely.

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.