You can do it right at the command line...

** make a backup of the file first just in case!! **

perl -pi -e "s|replace this text|with this text|g" somefile.txt

It will open somefile.txt, run the regex on each line of the file, and
replace the current file with the updated text.

Take a look at the perlrun manpage for details on thw switches.

Rob

-----Original Message-----
From: David Stoltz [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, December 18, 2002 2:32 PM
To: [EMAIL PROTECTED]
Subject: Search & Replace



Is there a way to open a text file in PERL, and search through it,
replacing a certain string with another string?

Thanks-

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to