473,396 Members | 1,760 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Help with appending text to file

Hi,

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
------------------
GrpA:xavi,jon,gwen
GrpB:ben,edward
GrpC:mary,ashley

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
2 2246
eWish
971 Expert 512MB
Have a look at Tie::File on CPAN.

--Kevin
Aug 1 '08 #2
KevinADC
4,059 Expert 2GB
Have a look at Tie::File on CPAN.

--Kevin
Excellent suggestion.
Aug 1 '08 #3

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

Similar topics

10
by: Bobby T | last post by:
Here's the problem, when I try to append an RDP file (which is written in hex but readable in notepad) it adds funny little squares to the file. I have tried opening the file in every mode but...
16
by: Michael | last post by:
I have a data application in a2k that I need to create two fixed width text files and then combine them to a single file The first file is header information and the second is transaction data. ...
4
by: Alessandro | last post by:
Hi. How can I save multiple reports to ONE text file? I've used the OutputTo function, but the result is one text file for each report. I'm not a MS Access programmer and I don't know if I can...
1
by: dibblm | last post by:
I have a text file being created and need the values from the array that gets created to populate my text file. I am new and not very good. Kinda borrowing bits and pieces from here and there, so...
2
by: Marc | last post by:
So i have a text file where each line represents a button name. What the code I need to read this file and creatre a new button from each line.. so far I just have code to read the whole...
5
by: llama.named.sue | last post by:
hey, Can someone please tell me is it possible to append to a text file using javascript?I've read that you can and that you can't and I'm lost now!I heard you can get around it by using xml?I...
6
by: portCo | last post by:
Hello there, I am creating a vb application which is some like like a questionare. Application read a text file which contains many questions and display one question and the input is needed...
21
by: Mick1000 | last post by:
Hi all, I am new to perl and this forum. I am trying to setup a mailing list subscription functionality for customers to receive a periodic newsletter from me. My perl program grabs the html form...
2
by: poolboi | last post by:
hi guys, i've got a problem in appending text file i'm creating a history log for people who use my my programs in my text file i got root Thu May 8 09:38:56 2008 Commands used: MIO:IMSI;...
7
by: elnoire | last post by:
Greetings! I've just started learning python, so this is probably one of those obvious questions newbies ask. Is there any way in python to check if a text file is blank? What I've tried to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.