File copying : File Copy « File « Perl






File copying

    


#!/usr/bin/perl -w

use strict;

my $source      = shift @ARGV;
my $destination = shift @ARGV;

open(IN, '<', $source)       or die "Can't read source file $source: $!\n";
open(OUT, '>', $destination) or die "Can't write on to file $destination: $!\n";

print "Copying $source to $destination\n";

while (<IN>) {
    print OUT $_;
}

close IN;
close OUT;

   
    
    
    
  








Related examples in the same category

1.Deal with \r character during file copy
2.Deal with the \r\n character during file copy