in reply to How to delete the line I have just read?
Hi,
If I am not wrong then follow this code
my $filename = 'yourfilename.txt'; open FILE, "$filename" || die "cant open file for read"; @data = <FILE>; close FILE; for my $line (0..$#data) { # execute process method -- do your operation stuffs here. &process($data[$line]); # if you want to delete, make the line with null value; $data[$line] = ""; } $entirefile = join "\n", @data; open OUT, "outfile.txt" || die "cant open file for write"; print OUT $entirefile; close OUT;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to delete the line I have just read?
by chromatic (Archbishop) on Aug 04, 2008 at 19:40 UTC |