Thursday, October 1, 2015

Copying contents of a file into another file using Perl Script

Copying contents of a file into another file using Perl Script.

#!c:\perl64\bin\perl.exe
use strict;
use warnings;

##################################################
#
#copying contents from file1 to file2
###################################################

open(FILE1,"<F:\\file.txt") or die ("Could not open the file",$!);
open(FILE2, ">>F:\\file1.txt") or die ("could not open the file",$!);

while(<FILE1>)
{
 print FILE2 $_;
}

close (FILE1);
close (FILE2);
print "text copied from file.txt to file1.txt\n";


No comments:

Post a Comment