OK.  I found the trouble.  It had nothing to do with the system command of
copying or moving the files.  The code snippet below is inside a foreach
loop.  That foreach loop was inside another foreach loop (don't ask) so I
was actually copying the files twice.  That is why the files appeared
identical.

Anyways, I did listen to the advice I was given and removed the system
command.  I am now using file::copy, copy(), and move() functions.

Thanks for the help.



> -----Original Message-----
> From: Adamiec, Larry 
> Sent: Thursday, July 01, 2004 13:35
> To: '[EMAIL PROTECTED]'
> Subject: using the system command
> 
> 
> I am running perl version 5.8.0 on a Sun Solaris 9.0 machine.
> 
> Given the following bit of code:
> 
>       $SOME_FILE = $_;
>       chomp($SOME_FILE);
>       $SOME_SAFE_FILE = $SOME_FILE . "_lax";
>       system ("cp '$SOME_FILE' '$SOME_SAFE_FILE'");
>       open (IN_FILE, "$SOME_FILE" );
>       open (TMP_OUT_FILE, ">$tmp_file" );
>       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?
> 
> Lawrence Adamiec
> Unix Manager
> Rm. 525B 
> 565 W. Adams St.
> Chicago-Kent College of Law
> Illinois Institute of Technology
> Chicago, Illinois
> 312-906-5301
> 

Reply via email to