Finding Position in a FILE??? 
Author Message
 Finding Position in a FILE???

I have an ascii file that looks like the following:


I want to find the  line with the name JOE in it and replace it with
some new data.

1.  How do I find the line number to replace?
2.  How do I replace the line?

Thanks in Advance for you help!

Sun, 11 Jan 1998 03:00:00 GMT  
 Finding Position in a FILE???

If you know that you need to modify only lines containing say Joe or some
known pattern, I don't see any particular reason as to why you need to know the
line number.

In any case, try the following code segment:


open(IN, "input.file");
open(OUT, "output.file");
while (<IN>) {
   print OUT unless /Joe/;


link("output_file", "input_file");

hope this helps,        

                        Jayaram Mulupuru                
218 N Hyland Avenue #302             237 Wilhelm, Scalable Computing Laboratory
    Ames, IA 50014                               Ames, IA 50011
(515)-292-7184 [Residence]                  (515)-294-1918 [Office]

Mon, 12 Jan 1998 03:00:00 GMT  
 [ 2 post ] 

 Relevant Pages 

1. fast way of finding position of regular expression

2. File position of of every word in a file

3. Please help - Find files recursively by File::Find

4. multiple file positioning

5. file position in Perl

6. File Position

7. Positioning in file?

8. Set current position in a file

9. Maintaining File position.

10. File marker position on partial reads

11. File position, seek function

12. find vs File::Find , regarding speed


Powered by phpBB® Forum Software