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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Languages » Perl
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://aspose.com/file-tools
 
subject: Replacing text in a file using perl script