467,114 Members | 1,324 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,114 developers. It's quick & easy.

Help with appending text to file


I have a file which store my grouping follow by the group members.
My codes will read in the new member name and the group. Then i will search for the group, ensure that the new member is not under the group and append the new member under the group. The problem is how do i append the name to that line?

File Sample

My codes:
Expand|Select|Wrap|Line Numbers
  1. $file='grouping';
  2. open(GRP, '>>'.$file)
  3. @lines=<INFO>;
  4. foreach $line (@lines)
  5. {
  6.    $grp=substr($line,0,4);
  7.    if($grp eq $grpinput)
  8.    {
  9.      seek(INFO,0,SEEK_CUR);
  10.      print INFO $line.','.$nameinput;
  11.    }
  12. }
Aug 1 '08 #1
  • viewed: 2119
2 Replies
Expert 512MB
Have a look at Tie::File on CPAN.

Aug 1 '08 #2
Expert 2GB
Have a look at Tie::File on CPAN.

Excellent suggestion.
Aug 1 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

10 posts views Thread by Bobby T | last post: by
4 posts views Thread by Alessandro | last post: by
1 post views Thread by dibblm | last post: by
2 posts views Thread by Marc | last post: by
5 posts views Thread by llama.named.sue@gmail.com | last post: by
6 posts views Thread by portCo | last post: by
2 posts views Thread by poolboi | last post: by
7 posts views Thread by elnoire@gmail.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.