Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can i append the string to each line inside the text file using perl?

Input file:t.txt
use strict
use warnings

output generated:

use strict
use warnings
aString

Expected output:

use strict aString
use warnings aString

What I have tried:

PERL
<pre> #!/usr/local/bin/perl
   open OUT,">>","t.txt" or die "error";
   #chomp(OUT);
   print OUT "aString";
   close OUT;
Posted
Updated 22-Feb-17 22:28pm

1 solution

 
Share this answer
 
Comments
example file 23-Feb-17 4:31am    
there they had used awk,sed and perl one liner .Here i trying to do with perl without using those editors.@Graeme_Grant
Graeme_Grant 23-Feb-17 4:33am    
This is pretty straight forward. So, I am not going to write your code for you ... time to do some more research.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900