Languages
[Edit]
EN

Perl - how to copy file in perl?

2 points
Created by:
Marcin
15710

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
50 000 ad impressions - 449$
🚀
Get your tech brand or product in front of software developers.
For more information contact us:
Red dot
Dirask - friendly IT community for everyone.

❤️💻 🙂

Join