in reply to Working on Deleting Sections of Text File Delimited by Newlines

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 ;-)

Replies are listed 'Best First'.
Re: (cLive ;-) Re: Working on Deleting Sections of Text File Delimited by Newlines
by belg4mit (Prior) on Nov 27, 2001 at 11:56 UTC
    please ="quote values"

    Here here! Never mind that it's the osking standard. They technically have to be there, yes yes prior to xHTML you were legally allowed to be lazy if your value was purely alpha-numeric. And no ' (tick) doesn't count.

    --
    perl -p -e "s/(?:\w);([st])/'\$1/mg"