CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Need a Custom or Prewritten Perl Program?: I need a program that...:
How to append to the end of a phrase

 



kektex
New User

Feb 25, 2005, 12:39 PM

Post #1 of 2 (1104 views)
How to append to the end of a phrase Can't Post

Hi,
I have a list of words that I need to append a suffix to in a text file, each word separated by a newline.
For example I have a list like this one:
aaa
bbb
ccc
and I want a perl script that can read each line and append the suffix xxx for example, so I get a new txt file with:
aaaxxx
bbbxxx
cccxxx

A friend referred me to this site since I don`t know any perl.
Can anyone give me a hand?


davorg
Thaumaturge

Mar 3, 2005, 4:31 AM

Post #2 of 2 (1014 views)
Re: [kektex] How to append to the end of a phrase [In reply to] Can't Post


In Reply To
Hi,
I have a list of words that I need to append a suffix to in a text file, each word separated by a newline.
For example I have a list like this one:
aaa
bbb
ccc
and I want a perl script that can read each line and append the suffix xxx for example, so I get a new txt file with:
aaaxxx
bbbxxx
cccxxx

A friend referred me to this site since I don`t know any perl.
Can anyone give me a hand?


No need for a program, just do it from the command line.


Code
$ perl -i~ -pe 'chomp; $_ .= "xxx\n"' your_filename_here


--
Dave Cross, Perl Hacker, Trainer and Writer
http://www.dave.org.uk/
Get more help at Perl Monks

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives