in reply to Error while Copying files from a directory to cwd

When I take a gander at the source code for File::Copy I see that there are some OS-specific differences in the implementation. There's even a line of code that does this:

return system('/bin/cp', '-f', $_[0], $_[1]) == 0;

You didn't mention what OS you were running this on. File::Copy is written in Perl, however, so it should be easy enough to debug into it and find out exactly where it is crashing on you. Here is a simple Perl debugger tutorial you might use.

Celebrate Intellectual Diversity

Replies are listed 'Best First'.
Re^2: Error while Copying files from a directory to cwd
by Anonymous Monk on Apr 21, 2011 at 15:03 UTC

    I am running it on windows machine,it can be xp,200X OR win7

      What, you don't know what operating you are running?

      At any rate, you may or may not have read that tutorial I listed by now but for anybody else lurking around as Anonymous you might consider doing this to see for yourself what might be wrong:

      use strict; use warnings; use File::Copy; use File::Find; use Cwd qw|cwd|; my $modem_build_ms = 'I have no clue what should go into model_build_m +s'; my $modem_build_location; my $dir=$ARGV[0]; my $currdir = Cwd::cwd(); print $dir; opendir(DIR, "$dir") || die "Error in opening dir $dir $!"; #die "Bad directory" unless (-d $dir); print "\n$modem_build_ms\n"; my %files = map {$_ => 1} qw(data.txt datascript.pl); find(sub { copy($File::Find::name, $currdir) or die "Can't cp $File::Find::na +me : $! " . Cwd::cwd() if delete $files{$_}; }, $dir); close DIR; __END__ Notice how the output says this: I have no clue what should go into model_build_ms Can't cp ./other/data.txt : No such file or directory C:/Temp/abba/oth +er at (eva l 24) line 20.

      I ran this code like this C:\Temp\abba>perl  runall.pl ./other which means that somewhere somebody moved me down into the target folder. If you run this with the argument to the script as the FULL file path however c:/temp/abba/other the code runs as expected.