Umesh T G <mailto:[EMAIL PROTECTED]> wrote:

: It is not copying the files, though there is no error printed on
: screen. :(

    It looks like you are not using warnings and strict. That
pretty much stops most errors from going to the screen.

    Your problem *may* be in @src. In perl, the file separator is
"/", not "\". "\" is an escape character. Change the array to
reflect perl's path structure.

        According to the File::Copy docs:

<quote>
 All functions return 1 on success, 0 on failure.
 $! will be set if an error was encountered.
</quote>

    See the code below for an example.


: my array contains all the source file names like this
:
: "..\..\..\AlgSource\ISA\C64x\asm\idct_8x8_c64xplus_h.asm"
:  "..\..\..\AlgSource\ISA\C64x\asm\jpegdec_ti_vld_n_mcu.asm"
:  "..\..\..\AlgSource\ISA\C64x\C\byte_unstuff.c"
:  "..\..\..\AlgSource\ISA\C64x\C\dc_pred_comp.c"

Change this to:

'../../../AlgSource/ISA/C64x/asm/idct_8x8_c64xplus_h.asm',
'../../../AlgSource/ISA/C64x/asm/jpegdec_ti_vld_n_mcu.asm',
'../../../AlgSource/ISA/C64x/C/byte_unstuff.c',
'../../../AlgSource/ISA/C64x/C/dc_pred_comp.c',


: Now, I want to copy all these files into a new dir   D:\newsrc\

    The copy() function you are using requires two file names.
The second argument has to be a file name and file path, not a
directory name. To extract the file name from a path above use the
File::Basename module.


: I tried like this,
: 
:
: Use File::Copy
:
: $newpath="D:\\newsrc\\";

my $newpath = 'D:/newsrc/';


: foreach $source (@src)

foreach my $source (@src)


: {
: print "COpying $source to $newpath \n";
: copy ("$source","$newpath");

    Don't quote variables needlessly. You need to code something
which will add a file name to $newpath. Always check I/O
operations for success.

copy( $source, "$newpath$filename" ) or
                die qq(Cannot copy "$source" to "$newpath$filename": $!);


HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to