Languages
[Edit]
EN

Perl - how to copy file in perl?

2 points
Created by:
Maggotta
499

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;

 

Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
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