|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
open file find and replace
was wondering where i could find info on opening afile finding text and then replacing it with a variable in
Thank you in advance Wicked- |
|
#2
|
|||
|
|||
|
I believe this will do it:
Code:
open (INFILE, "</path/filename") or die "Cannot open filename for input: $!";
while (<INFILE>) {
s/oldtext/$newtext/g;
$replace .= $_;
}
close INFILE or die "Cannot close filename: $!";
open (OUTFILE, ">/path/filename") or die "Cannot open filename for output: $!";
print OUTFILE $replace;
close OUTFILE or die "Cannot close filename: $!";
|
|
#3
|
|||
|
|||
|
thank you I will try that today
Wicked- |
|
#4
|
|||
|
|||
|
thanx
this is the code that actually did it. s/oldtext/$newtext/g; $replace .= $_; my book shows this code but no way of using it. thanx again, |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > open file find and replace |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|