Errr... something that springs to mind is that you create a cgi object $q (lovely), and then proceed to ignore it and do all your HTML by hand. wtf (that's why, not what :-). I suggest you read the CGI docs and maybe take a look at a couple of my recent posts.

Anyway, apart from that (slap), if you insist on hand crafting inputs, please ="quote values" - you'll understnad why if you ever have a value that contains a space!

You say 3 lines is the delimiter, so why:

$/="\n\n"; # instead of $/="\n\n\n";
?

OK, a few more notes. Here's how I'd parse (without rewriting this massively ;-)

if ( $q->param() ) { open (FH, "$path_to_text") or die "where's the damn file? : $!"; # also set this in earlier part to match $/="\n\n\n"; #set the input Record seperator to a TPIPLE newline my @updated_text; while (<FH>) { next if /^\n+$/; #ignore lines which contains onl +y newlines $post_number++; # ignore deleted next if ( $q->param("box$post_number") ); # keep the rest push @updated_text, $_; } close(FH); # now update file open(FH,">$path_to_text") || die $!; print FH join "\n\n\n", @updated_text; close(FH); # show success here... }

hth

cLive ;-)


In reply to (cLive ;-) Re: Working on Deleting Sections of Text File Delimited by Newlines by cLive ;-)
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.