Not tested. I am sure there is a more elegant way to do this but this should do the trick. It will create a new file with the changes. If you want to edit it inline you will have to do some research.
#Open files for input and output open (IN,"<myfile") or die "Can not open file\n"; open (OUT,">outfile") or die "Can not open file for writing\n"; my ($password,$login)=('password','login'); while(<IN>){ chomp; #Assuming that password is at start of line and only thing on line. if (/^password=/){ print OUT "password=\"$password\";"; next; } if (/^login=/){ print OUT "Login Id = \"$login\";"; next; } print OUT "$_\n"; } -----Original Message----- From: Bob Showalter [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 13, 2003 10:56 AM To: 'Pankaj Kapare'; [EMAIL PROTECTED] Subject: RE: File handling Pankaj Kapare wrote: > Hi > I want to to file handling in perl.In that I have one file which > contains some lines.Now I want to modify some of lines like.. My file > conatins line one line two > line three > password="password"; > Login Id ="xyz" > line 6 > and so on > > if i want to write new passord and login id then how can i do that? > Can anybody help me with sample code Thanks in advance! > Pankaj Start with the FAQ article: perldoc -q 'change one line' -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]