On Thursday 01 July 2004 11:34, Adamiec, Larry wrote:
>
> 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 $_;
>        }
>       }

You can "simplify" that a bit:

use File::Copy;
chomp;
copy( $_, $_ . '_lax' );
local ( $^I, @ARGV ) = ( '.bak', $_ );
while ( <> ) {
    s/(?<=<!--########)/ /;
    print;
    }


> 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?

Yes.


John
-- 
use Perl;
program
fulfillment


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to