I want in.txt and out.txt file to be same. That is I want to replcae text insa me file and do not want to create a new file. Thanks, Vinay ----- Original Message ----- From: "Jeff 'japhy' Pinyan" <[EMAIL PROTECTED]> To: "Vinay Thombre" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Tuesday, August 05, 2003 10:52 PM Subject: Re: How to replace a text in a file
> On Aug 5, Vinay Thombre said: > > >I am novice to Perl and learning very basic things. I want to replace a text > >in a file with new text. I want to do it programatically. How can I do that? > > I hope you've got a good book or two, such as "Learning Perl" (the llama > book) published by O'Reilly. > > The basic setup you'll want to use is this: > > open INPUT, "< in.txt" or die "can't read in.txt: $!"; > open OUTPUT, "> out.txt" or die "can't write out.txt: $!"; > while (my $line = <INPUT>) { > # do something to $line > print OUTPUT $line; > } > close OUTPUT; > close INPUT; > > -- > Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ > RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ > <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course. > [ I'm looking for programming work. If you like my work, let me know. ] > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]