Title: RE: reading/writing to a ascii file

That is still opening and reading the entire file and then creating an entire new file... I may run into instances where the file will be opened and modified many times.

-----Original Message-----
From: Thomas, Mark - BLS CTR [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, October 28, 2003 9:53 AM
To: 'Farrington, Ryan'; [EMAIL PROTECTED]
Subject: RE: reading/writing to a ascii file


Ryan, it's easier than you think:

open(IN, "<$inputfile") or die "can't open $inputfile: $!";
open(OUT,">$outputfile") or die "can't open $outputfile: $!"; while (<IN>){
        s/$string/$replacement/g;
        print OUT $_;
}
close IN;
close OUT;
rename($outputfile, $inputfile) or die "can't rename... $!";


--
Mark Thomas                    [EMAIL PROTECTED]
Internet Systems Architect     User Technology Associates, Inc.

$_=q;KvtuyboopuifeyQQfeemyibdlfee;; y.e.s. ;y+B-x+A-w+s; ;y;y; ;;print;;
 

Reply via email to