http://www.perlmonks.org?node_id=1069476


in reply to Replace a string after a word

As I understood you want the filename to be user=newvalue and the string "user=newvalue" to be written to that file:
#!/usr/bin/perl # # use strict; use warnings; my $teststring = '"user={hhhfj}jshdfjhdfjh\="'; my $own_value = "newvalue"; if ( $teststring =~ /\"user=.*/ ) { $teststring =~ s /\"user=.*/\"user=$own_value\"/; my $filename = $teststring; print $teststring, "\n"; $filename =~ s/\"//g; #you don't want " in an filename open my $outfile, ">", $filename; print $outfile $teststring; close $outfile; }