D
Devop
HI. every one.
I wanted to search a string from a file, then replace it, and write to
the file again.
But i have come up with this solution, where the replaced contents will
be written in to the an other file.
But it does not work.
This error is coming :
Use of uninitialized value in substitution (s///)
Is there any other way to solve this problem. Thanks.
#!/usr/bin/perl -w
#use strict;
use warnings;
my $infile = 'first.xml';
my $outfile = 'second.xml';
my $text1 = 'this is it =';
my $text2 = '{and this is a new} OK '';
undef $/;
open IN, $infile or die "couldn't open the file!";
my $intext = <IN>;
close IN;
$intext =s/$text1/$text2/gi;
open OUT, ">$outfile" or die $!;
print OUT $intext;
close OUT;
I wanted to search a string from a file, then replace it, and write to
the file again.
But i have come up with this solution, where the replaced contents will
be written in to the an other file.
But it does not work.
This error is coming :
Use of uninitialized value in substitution (s///)
Is there any other way to solve this problem. Thanks.
#!/usr/bin/perl -w
#use strict;
use warnings;
my $infile = 'first.xml';
my $outfile = 'second.xml';
my $text1 = 'this is it =';
my $text2 = '{and this is a new} OK '';
undef $/;
open IN, $infile or die "couldn't open the file!";
my $intext = <IN>;
close IN;
$intext =s/$text1/$text2/gi;
open OUT, ">$outfile" or die $!;
print OUT $intext;
close OUT;