EN
Perl - how to copy file in perl?
2
points
Using perl it is possible to copy file in following way.
1. Rewrite one file to another file example
copy_file.pl
file:
#!/usr/bin/perl
scalar(@ARGV) == 2 || die('Expected two arguments (file paths).');
$iname = $ARGV[0];
$oname = '>' . $ARGV[1];
open(ifile, $iname) || die('Input file error!');
open(ofile, $oname) || die('Output file error!');
while($line = <ifile>)
{
print ofile $line;
#print $line;
}
close ifile;
close ofile;