PDA

View Full Version : another file problem


crca
11-02-2002, 05:15 AM
PROBLEM:
I have a plain text file data file seperated ny new lines
place 1
place 2
place 3

and i need to delete place 2 without removing other lines of text. How do i do this?

chrisvmarle
11-02-2002, 12:02 PM
Try this, haven't test it my self, 'cuz I don't have much time right now but felt like helping you as much as I can.

open(FILE,"textfile.txt");
@all_places = <FILE>;
close(FILE);

open (FILE,">textfile.txt");
foreach $place (@all_places) {
chop($place) if ($place =~ /\n$/);
if ($place ne "place 2") {
print FILE $place . "\n";
}
}
close (FILE);

Mzzl, Chris