aspose file tools
The moose likes Perl and the fly likes Replacing text in a file using perl script Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Languages » Perl
Reply Bookmark "Replacing text in a file using perl script" Watch "Replacing text in a file using perl script" New topic
Author

Replacing text in a file using perl script

Patricia Samuel
Ranch Hand

Joined: Sep 12, 2007
Posts: 300
Hi All,

I need to replace some value in config file using perl script. I used this code -


When i print $file , it shows me the changed rows but it does not write it to a file. Please suggest.

Regards,
Patricia samuel
James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

Since your are reading the whole file into memory you can safely re-open the file and write to it i.e.



Retired horse trader.
 Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Replacing text in a file using perl script
 
Similar Threads
unix2dos command in perl script
Naming policy
Writing a file and executing
Running perl from java
servlet calling perl script - script hangs