> > > > > > I am running perl version 5.8.0 on a Sun Solaris 9.0 machine. > > > > Given the following bit of code: > > > > use strict; > use warnings; > > > $SOME_FILE = $_; > > chomp($SOME_FILE); > > $SOME_SAFE_FILE = $SOME_FILE . "_lax"; > > system ("cp '$SOME_FILE' '$SOME_SAFE_FILE'"); > > This is an insufficient use of 'system', you should use full paths, > taint checking, check return codes, etc. I would suggest using > File::Copy instead. > > perldoc File::Copy > > > open (IN_FILE, "$SOME_FILE" ); > > open (TMP_OUT_FILE, ">$tmp_file" ); > > Right here you are opening for writing (read: clobbering, so why copy?) > > I am coping the original file for safe keeping in the event I screw up > things. > > $tmp_file, so why would $SOME_SAFE_FILE have changed? > > That's what I want to know. > > > while (<IN_FILE>) { > > if ( /\<\!--########/ ) { > > s/(\<\!--########)(.*)/\<\!-- ######## $2/; > > print TMP_OUT_FILE $_; > > } > > else { > > print TMP_OUT_FILE $_; > > } > > } > > > > When I check the contents of $SOME_FILE, I can see that the file has been > > edited correctly. However, the contents of $SOME_SAFE_FILE have been > edited > > also. Given this code, shouldn't $SOME_FILE be different from > > $SOME_SAFE_FILE? > > > > Are you sure $SOME_FILE has been edited, what is in $tmp_file? > > $tmp_file replaces $SOME_FILE Here is that bit of code: > > close (IN_FILE); > print TMP_OUT_FILE "\n"; > close (TMP_OUT_FILE); > system ("mv '$tmp_file' '$SOME_FILE'"); >
Again you should avoid shelling out to 'mv', use the built-in 'rename' function or File::Copy's 'move' method instead. perldoc -f rename perldoc File::Copy Either way what does $tmp_file the variable contain? You haven't shown us that one, and that is the one that is getting edited. http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>