I have a perl function in my script that needs to replace an entire line in a file
sub changestate {
my $base = ();
my @base = ();
open(BASE, $file) || die("Could not open file!");
@base=<BASE>;
close (BASE);
foreach $base(@base)
{
if($base =~ /sslCACert=/){
$base =~ s/sslCACert=/sslCACert=myserver.domain\/path/gi;
print ("Hello, world!\n");
}
open (BASE, ">$file");
print BASE @base;
close (BASE);
};
}
the problem is the line:
base =~ s/sslCACert=/sslCACert=myserver.domain\/path/gi;
The base sslCACert= I want to replace is followed by random garbage depending on which machine the file is on the only thing constant is sslCACert= . Can i use any wildcards? Also does a \ escape a / like in a shell script with perl. The Hello World is just there for testing.
Sean