in reply to updating a file
I didn't actually run this, but it should be close. You might want more descriptive diemessages.use File::Copy; open(RFH, "<ReadFile.h") or die "Trying:$!"; open(WFH, ">WriteFile.h") or die "Trying:$!"; while(<RFH>) { s/search/replace/; print WFH; } close RFH; close WFH; move ("WriteFile.h", "ReadFile.h") or die "With a vengance:$!";
The idiomatic way to do this would be with an 'in place edit' that does the file move for you.
This will save the old file as "header.h.old" for you.$^I = '.old'; @ARGV = ("header.h"); while (<>) { s/search/replace/; print; }
Ira,
"So... What do all these little arrows mean?"
~unknown
|
|---|