Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9083907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:52:54+00:00 2026-06-16T20:52:54+00:00

Below code is the part of the script, in which I am merging files

  • 0

Below code is the part of the script, in which I am merging files of different directories. After merging I am copying remaining files into final directory.
Merging is working fine but while copying files I am getting

cp: missing destination file operand after `/users/abc/perl_scripts/temp_dir/b.cc'
Try `cp --help' for more information.
sh: line 1: /users/abc/perl_scripts/temp: is a directory

for $k(dir1) {
     $flag=0;
     for $j(@dir2) {
          if("$k" eq "$j") {
               &merge_gcov("$UERRC1/$k","$UERRC2/$k","$DATA_DIR/$k");
               $flag=1;
               last;                            
          }
     }
     if($flag == 0) {
           #print ">>>>>>>>>>>>> cp $UERRC1/$k $DATA_DIR/$k \n";
           'cp $UERRC1/$k,$DATA_DIR`;
     }
 }

Can anybody help me to resolve this…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T20:52:55+00:00Added an answer on June 16, 2026 at 8:52 pm

    Whenever you are using system calls you are most likely doing something redundant, and it certainly is redundant in this case. Perl is very capable of copying files. I recommend the File::Copy module, which is a core module in perl 5. Using it is simple:

    use File::Copy qw(copy);
    copy $from, $to or die $!;   # it is a good idea to check if the copy failed
    

    Also, instead of looping over all the file names in @dir2 and see if the name matches the one in $k, why not just check if the file exists in the other directory? E.g.

    if (-e "$UERRC1/$k") {    # check if file exists
        merge_gcov("$UERRC1/$k", "$UERRC2/$k", "$DATA_DIR/$k"); 
    } else { 
        copy "$UERRC1/$k", $DATA_DIR or die $!; 
    }
    

    The documentation for the file test -e is found in perldoc -f "-X"

    You really should use variable names that are more appropriate. It will make your code more readable and much easier to maintain and debug.

    Also…

    Before you do anything else, you should add the following two lines to your script and fix the errors that undoubtedly appear:

    use strict;
    use warnings;
    

    strict will force you to declare all variables (typically with my $foo) which will remove hard to detect bugs due to typos in variable names. The error message will read “Global symbol $foo requires explicit package name …”.

    warnings will give you information about things that you are doing wrong. This is a good thing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm uploading some files. Below is part of the script for the upload (I'm
I have part of the code below: while($array = $result->fetch_assoc() ){ $second_query = INSERT
In the code below, I think I messed up this part: if ( (1
20120315021529.000[-8:PST] to get the first part I was able by using below C# code.
Below, I inserted a code written by Ray Konopka (part of the Coderage presentation).
Below code saying error incorreect syntax near Main INSERT INTO tbl ( 'Week', Main,
I have a pagination script which I have posted below, the problem is I
I am using this particular part of code which i found on the net,
Below is the code I am running within a service. For the most part
Follow the below part of the code: driver.get https://example.com/ element = driver.find_element :name =>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.