I want to read the value of variable from environment file and set it to another properties file using perl script.
Environment File
DOMAIN=<value> DOMAIN_TEST_DB_CONN_STR=<value> DOMAIN_TEST_DB_USER=<value> DOMAIN_TEST_DB_PSWD=<value>
Properties File
#These are the properties for engineering #We expect you to change them for your environment # #CustomerDatabase info DOMAIN=<value> DOMAIN_TEST_DB_CONN_STR=<value> DOMAIN_TEST_DB_USER=<value> DOMAIN_TEST_DB_PSWD=<value>
I tried following but not working. Kindly please suggest.
$envfile="/root/env.properties"; @envFile=<$env>; open my $env, '<', $envfile or die "Can't read old file: $!"; open my $in, '<', $file or die "Can't read old file: $!"; open my $out, '>', "$file.new" or die "Can't write new file: $!"; print "\nFile contents:"; print @envFile; foreach $envline (@envFile){ while ( <$in> ){ print "$. $_"; if($envline =~/$DOMAIN_DB_CONN_STR=.*:1521:.*/ && $_=~/$DOMAIN +_DB_CONN_STR=.*:1521:.*/){ print "\nMatch"; $line=$_; $line =~ s/$DOMAIN_DB_CONN_STR=.*:1521:.*/NUANCE_DB_CO +NN_STR=$dbhost:$dbport:$dbschema/; print $out $line; } } }
In reply to read the value of variable from environment file and set it to another properties file using perl script by vishallearningperl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |