Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Parse a file, replace a particular strings and save new file

by ig (Vicar)
on Nov 13, 2013 at 06:15 UTC ( #1062335=note: print w/replies, xml ) Need Help??


in reply to Parse a file, replace a particular strings and save new file

You might find Getting Started with Perl helpful. There are references to many resources there.

  • Comment on Re: Parse a file, replace a particular strings and save new file

Replies are listed 'Best First'.
Re^2: Parse a file, replace a particular strings and save new file
by sanku (Beadle) on Nov 13, 2013 at 09:36 UTC
    Hi, Try this code
    my ($v1,$value,$i); open (FILE,"old.txt") or die $!; open (NEW,">new.txt") or die $!; while(<FILE>){ if($_ =~/string_/){ ($v1, $v2) = split(/name/,$_); ($value) = split(/\(/,$v2); } $_ =~s/values/$value/; print NEW $_; } ~

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2020-09-30 10:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If at first I donít succeed, I Ö










    Results (160 votes). Check out past polls.

    Notices?