in reply to Working on Deleting Sections of Text File Delimited by Newlines
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 |