Hello All,
I have two lines as follows in my file.
<start>start of program<end>
<start>string to be replaced<end>
These lines are in the middle. There are blank spaces before the promt <. The sentence 'string to be replaced' need to be replaced by the sentence 'changed'.
The sentences 'string to be replaced is not always the same.
So i would like to delete the line 'string to be replaced and add my new sentence 'changed'.
I have tried the code,
As i told earlier the two sentences are in the middle with blank spaces before it, How could i incorporate it and print the first line as it and then change my second line to 'changed'.
Ramesh
I have two lines as follows in my file.
<start>start of program<end>
<start>string to be replaced<end>
These lines are in the middle. There are blank spaces before the promt <. The sentence 'string to be replaced' need to be replaced by the sentence 'changed'.
The sentences 'string to be replaced is not always the same.
So i would like to delete the line 'string to be replaced and add my new sentence 'changed'.
I have tried the code,
Code:
while (<IN>){
my $file = $_;
if ($file =~ /\start of program/){
print OUT $file;
$file=<IN>;
}
$file =~ s/ /changed/g;
}
Ramesh
Comment