On 01/28/2016 04:59 PM, Logust Yu via beginners wrote:
> You can probably achieve this easily with 'sed' on bash. 
> 
>> On 28 Jan 2016, at 09:37, Frank Larry <frankylarry2...@gmail.com> wrote:
>>
>> Hi Team,
>>
>>  could you please let me? i have a file which contains "Debug", i would like 
>> to replace debug to "Error", when i ran the below program the out showing 
>> Error message but how to save the output with new changes. Could you please 
>> tell me how to fix it?
>>
>> open(FILE, "<filter.txt") or die "Can’t open $!\n"; 
>>
>> while($line = <FILE>){ 
>>    print "Before substituting: ", $line ,"\n"; 
>>     $line =~ s/Debug/Error/g;     
>>     print "After substituting : ", $line , "\n"; 
>>      
>> }  
>>
>> close(FILE);
>>
>>
>> -Franky

Or a one-liner would work, if the replacement above really is what you want:

perl -pi.orig -e 's/Debug/Error/g;' filter.txt

The old file will be named filter.txt.orig and the new file with the
substitutions will be filter.txt

See the manual page for perlrun(1) for the details of the options e, i,
and p.

Regards,
Lars

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to