CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Modifying .txt file

 



tej.87g
Novice

Jul 13, 2010, 8:54 PM

Post #1 of 3 (383 views)
Modifying .txt file Can't Post

I want to modify one text file, I don't want to make other file..is it possible to make changes in the same file?..

If yes How?

Thank you..Wink


(This post was edited by tej.87g on Jul 13, 2010, 8:55 PM)


rovf
Veteran

Jul 14, 2010, 2:06 AM

Post #2 of 3 (380 views)
Re: [tej.87g] Modifying .txt file [In reply to] Can't Post

(1) See the -i switch (perldoc perlrun), but it does not exactly fit your requirments (under the hood, it does make a new file, though you won't notice it).

(2) If you *know* what you are doing (for example, because though you are a beginner in Perl, you have experience in C), you can open the file using '+<' as open mode, and use sysread, syswrite, sysseek to process the file. Of course you have to take care about line endings by yourself.


Zhris
Enthusiast

Jul 14, 2010, 3:49 PM

Post #3 of 3 (371 views)
Re: [tej.87g] Modifying .txt file [In reply to] Can't Post

(3) Perl module Tie::File (http://search.cpan.org/~mjd/Tie-File-0.96/lib/Tie/File.pm).

Chris


(This post was edited by Zhris on Jul 14, 2010, 3:50 PM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives