Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Replace a string after a word

by walto (Pilgrim)
on Jan 06, 2014 at 09:17 UTC ( [id://1069476]=note: print w/replies, xml ) Need Help??


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; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1069476]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2026-01-23 10:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (125 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.