Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I am just reading the name and comments as arguments then appending it to the file:EmpInfo ------- John #4 - sleep too much - came late on 04/04/04 - not shaved on 03/03/04 Kim #45 - good job - comes early Mike #3 - not nice
My problem is , I am not sure how to append the correct line, if a new comments to be added for John , example "He is too fat" then I need the file to look like this:my $nameOfEmp; my $comments; open (DATA, "EmpInfo") or die "can't open file\n"; while (my $line = <DATA> ){ if /^$nameOfEmp { next if /^\-; print DATA $comments; } }
excuse my question , I am new to perl . thanksEmpInfo ------- John #4 - sleep too much - came late on 04/04/04 - not shaved on 03/03/04 - He is too fat Kim #45 - good job - comes early Mike #3 - not nice
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re: Append to correct place in a file
by merlyn (Sage) on Apr 15, 2004 at 15:54 UTC | |
|
Re: Append to correct place in a file
by davido (Cardinal) on Apr 15, 2004 at 16:28 UTC | |
|
Re: Append to correct place in a file
by meredith (Friar) on Apr 15, 2004 at 16:29 UTC | |
|
Re: Append to correct place in a file
by Thelonius (Priest) on Apr 15, 2004 at 16:17 UTC | |
|
Re: Append to correct place in a file
by waswas-fng (Curate) on Apr 15, 2004 at 16:42 UTC | |
by pbeckingham (Parson) on Apr 15, 2004 at 17:26 UTC | |
|
Re: Append to correct place in a file
by simonm (Vicar) on Apr 15, 2004 at 15:56 UTC |