http://qs321.pair.com?node_id=1121904


in reply to Can't copy file

novice2015 has asked for the wisdom of the Perl Monks concerning the following question:

     I am a total beginner

Excellent -- and welcome to the Monastary. Please add the following to your script; I strongly urge you to never remove them:

     #!/usr/bin/perl
     use strict;
     use warnings;
     my $server = `uname -n`;
     print $server;
     chomp $server;
     # Display all the files in /tmp directory.
     
my $dir = "/usr/ent/newdir/db/sign/*";
     my @files = </usr/ent/newdir/db/sign/*files*>;
     open(my $outfh, '>', '/tmp/output1.txt') or die "cannot open file";
     foreach
my $LINE (@files ){
         print $outfh $LINE;
         close FH;
     }
     use File::Copy;
     {
         
my $oldlocation = "/tmp/output1.txt";
         
my $newlocation = "/tmp/output3.txt";
         copy($oldlocation, $newlocation);
     }
     exit;