I copied your directory set up, along with the filename, and ran your script on perl-5.12.0 on Windows 7 and it worked fine for me.
I did add a couple of lines to check that both the file ($source) and the destination directory ($target) existed:
use strict;
use warnings;
use File::Copy;
my $source="C:\\sandboxes\\source_backup\\source_backup\\source_develo
+p\\source_folder\\source_part\\source_specific\\source_common\\rb_src
+c_sourcedevelopfolderpartspe_Interfacessourcecommonspecific.h";
my $target="C:\\sandboxes\\target_backup\\target_backup\\target_develo
+p\\generated\\_hnv_scan\\_source_develop\\source_folder\\source_part\
+\source_specific\\source_common";
print "OK 1\n" if -e $source;
print "OK 2\n" if -d $target;
copy($source,$target) or die "could not do: $!";
print ("done");
I got:
C:\_32\pscrpt>perl try.pl
OK 1
OK 2
done
C:\_32\pscrpt>
However, the first time I ran it, it failed because I had not named the $target directories correctly.
I had missed the underscores at the beginning of "_hnv_scan" and "_source_develop", and the script therefore produced:
C:\_32\pscrpt>perl try.pl
OK 1
could not do: at try.pl line 10.
Please do check that both the $target directory and $source file do actually exist, as it seems to me that the most likely explanation of your issue is a typographical error.
Cheers,
Rob
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.