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: Perl Programming Help: Beginner:
Adding lines of text to a file

 



tboss888
New User

Aug 14, 2008, 4:44 AM

Post #1 of 2 (476 views)
Adding lines of text to a file Can't Post

Hi all,

I did a cursory search but was unable to find anything.

I'm trying to edit a txt file using perl. What I want to do is add 3 lines of text to a certain line number in an existing file. Can anyone point me in the right direction to accomplish this. I am able to count the line numbers but I'm not sure what to do next.

ie.

Old file


Code
  

a

b

f

g



New file


Code
  

a

b

c

d

e

f

g



KevinR
Veteran


Aug 14, 2008, 12:40 PM

Post #2 of 2 (462 views)
Re: [tboss888] Adding lines of text to a file [In reply to] Can't Post

Use Tie::File or perls inplace editor. Post the code you have written so far.
-------------------------------------------------

 
 


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

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