in reply to adding an element in existing file..

It kinda looks like this is really a colon-delimited format. If so, I recommend using DBI and DBD::CSV, and set the delimiter to a colon. It's way easier to adapt your code then to other formats, whether other formats handled by DBD::CSV or other database applications.

  • Comment on Re: adding an element in existing file..

Replies are listed 'Best First'.
Re^2: adding an element in existing file..
by bran4ever (Novice) on Jun 04, 2006 at 02:35 UTC
    My apologies...here it is:
    if($passwd ne "") { $depass = decode_base64($passwd); print "read this----->$depass\n"; @name = split(/:/,$depass); chomp $name[0]; chomp $name[1]; open(FH, "<userlist.txt"); while (<FH>) { $line = $_; chomp $line; @listuser = split(/:/,$line); chomp $listuser[0]; chomp $listuser[1]; #if user is eligible if (($name[0] eq $listuser[0]) && ($name[1] eq $listuser[1])) { print "this is @name[0] = @listuser[0] : @name[1] = @listuser[1]\n"; print "juz above web sock new\n"; $web = IO::Socket::INET->new(PeerAddr => +$host,PeerPort=>80) or die "$@"; #send request to web server print "I'm juz above the syswrite web\n"; print "WEB SOCK >> $web \n"; print "BUFFER >> $buffer1\n"; syswrite($web,$buffer1); #buffer3 is the web data while($bytes = sysread($web,$buffe +r3,1024)>0) { #output the data to bro +wswer syswrite($browser, $buffer3) +; @nameLine += (split (/\n/, $line)); @byteadd = + (split (/:/, $line)); open(FH, " +>>userlist.txt") or die ("Error, cannot be opened"); + $listuser[2] = $downloadTo +tal; print(FH $ +listuser[2]); close(FH); + last; } }