Writing at exact location in file

Discussion in 'Perl Misc' started by rahulthathoo, Nov 3, 2006.

  1. rahulthathoo

    rahulthathoo Guest

    Hi
    I want to write to a file - which already exits and has some
    data in it. I dont want to erase that data. Say suppose it has 30
    lines of text in it. I want to write something in the first line after
    the first two words. How do i go about it. I know how to open a file
    but I am not able to seek to the right position and not able to write
    my text without deleting the entire data of the file but i dont want
    that. Can you help me here.

    Thanks
    Rahul
    rahulthathoo, Nov 3, 2006
    #1
    1. Advertising

  2. On 11/02/2006 11:49 PM, rahulthathoo wrote:
    > Hi
    > I want to write to a file - which already exits and has some
    > data in it. I dont want to erase that data. Say suppose it has 30
    > lines of text in it. I want to write something in the first line after
    > the first two words. How do i go about it. I know how to open a file
    > but I am not able to seek to the right position and not able to write
    > my text without deleting the entire data of the file but i dont want
    > that. Can you help me here.
    >
    > Thanks
    > Rahul
    >


    The module Tie::File will let you treat a file as an array in Perl.

    Start->Run->"perldoc Tie::File"


    --
    Mumia W. (reading news), Nov 3, 2006
    #2
    1. Advertising

  3. rahulthathoo

    rahulthathoo Guest

    Thanks
    Mumia W. (reading news) wrote:
    > On 11/02/2006 11:49 PM, rahulthathoo wrote:
    > > Hi
    > > I want to write to a file - which already exits and has some
    > > data in it. I dont want to erase that data. Say suppose it has 30
    > > lines of text in it. I want to write something in the first line after
    > > the first two words. How do i go about it. I know how to open a file
    > > but I am not able to seek to the right position and not able to write
    > > my text without deleting the entire data of the file but i dont want
    > > that. Can you help me here.
    > >
    > > Thanks
    > > Rahul
    > >

    >
    > The module Tie::File will let you treat a file as an array in Perl.
    >
    > Start->Run->"perldoc Tie::File"
    >
    >
    > --
    >
    rahulthathoo, Nov 3, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. HNguyen
    Replies:
    4
    Views:
    2,382
    HNguyen
    Dec 21, 2004
  2. Andy B
    Replies:
    5
    Views:
    572
    Andy B
    May 29, 2008
  3. Michelle Ang
    Replies:
    1
    Views:
    367
  4. Brett Foster

    Exact Location of an Element

    Brett Foster, Feb 21, 2005, in forum: Javascript
    Replies:
    1
    Views:
    86
    Fred Oz
    Feb 21, 2005
  5. Peter Olcott
    Replies:
    10
    Views:
    139
    Evertjan.
    Aug 15, 2006
Loading...

Share This Page