Languages
[Edit]
EN

Perl - how to copy file in perl?

2 points
Created by:
Marcin
18850

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;

 

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join