bh_perl has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's minimum standard of quality and will not be displayed.

Replies are listed 'Best First'.
Re: How to append record at the existing record ?
by grep (Monsignor) on Nov 15, 2006 at 04:26 UTC
    When asking a question like this it's best to include the code you are trying to get working. Else we have little idea where your specific problem is and how to guide you.

    Generally if the file isn't too big just feed it into an array. Then append the array with your new info and print it out.

    use strict; use warnings; open(FH,'<','input') or die "$!\n"; my @array = <FH>; close FH; push(@array,"Your new data\n"); open(OUT,'>','output') or die "$!\n"; print OUT @array;

    Try reading: How (Not) To Ask A Question and I know what I mean. Why don't you?

    grep
    XP matters not. Look at me. Judge me by my XP, do you?

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: How to append record at the existing record ?
by ikegami (Patriarch) on Nov 15, 2006 at 04:28 UTC

    bh_perl, please stop putting your entire post in code tags. You've been asked many times before. I'm sure the janitors would like to stop having to edit your posts. You should have entered your post as follows:

    <p>Hi, <p>I have an input file as below:- <c> Name: saya Mobile: 013 Name: ken Mobile: 019 </c> <p>Right now i can read the input data and split it with new line (\n) +. But How could i append a new data at the begining and last of the r +ecord, as example:- <c> Title: Executive Name: saya Mobile: 013 done </c> <p>Could somebody help me and give some example ?

    As for your problem, the easiest way is to use local $/ = '';.

Re: How to append record at the existing record ?
by arunmep (Beadle) on Nov 15, 2006 at 06:53 UTC
    open(fd1,"log.txt") or die"unable to open"; open(fd2,">>log2.txt"); while($getVal=<fd1>) { if($getVal=~/name/) { $getVal="Designation :Manager\n".$getVal; } print fd2 $getVal; } close(fd1); close(fd2);

    Edited by planetscape - added code tags