Please help...

*This is the original line in outFile*
*This goes into inFile*

I was expecting to find the two lines above in the file "*outFile*" after
running the code below:

#!/usr/bin/env perl

use 5.010;

 `touch inFile`;
 `touch outFile`;
 `chmod 744 inFile`;
 `chmod 744 outFile`;
 `echo "This goes into inFile" > inFile`;
 print "Finished writing to inFile\n";
 `echo "This is the original line in outFile" > outFile`;
 print "Finished writing to outFile\n";

open(IN,"inFile")
        || die "cannot open input file";
        print "Input file opened...\n";

open(OUT,"outFile")
        || die "cannot open output file";
        print "Output file opened...\n";

while(<IN>)
        {
                print OUT $_;
                print "Data entered in outFile\n";
        }
close(IN);
close(OUT);

 `echo "This 2nd line goes into inFile" >> inFile`;
 print "Finished writing to inFile\n";
 `echo "This is the 2nd original line in outFile" >> outFile`;
 print "Finished writing to outFile\n";

This is the output on the console:

Finished writing to inFile

Finished writing to outFile

Input file opened…

Output file opened…

Data entered in outFile

Finished writing to inFile

Finished writing to outFile

When I open the "outFile", I find this single line instead of the expected
two:

*This is the original line in outFile*

I was expecting to find this line as well: *This goes into inFile*, in the
"outFile"l.
It seems between the "*open(IN...)*" and "*close(OUT)*" something is not
working but I cannot figure it out.

Please assist.

Joseph.

-- 
Isaiah 40:31 "But they that wait upon the LORD shall renew their
strength..."

Reply via email to