[ Please do not top-post ]

anu p wrote:
> If you have some time to help me out ...

You should post your questions to the mailing list instead of individual
subscribers.

> I tried a similar example of recursive copy using File::Find, Copy.
> I tried to copy all files with extension ".c" to a directory. After
> the first file is copies, I start getting messages saying "No such
> file or directory". I am not sure where am I going wrong..
> 
> The files are like this:
> 
> perl -> a.c
> perl/b -> b.c
> perl/b/c -> c.c etc.
> 
> Code:
> 
> my $from_dir = "/home/anupamaperi/perl";
> my $to_dir = "temp";

"temp" is a relative directory.  You need to use an absolute directory like
the one in $from_dir.


> my $found_count = 0;
> 
> find (\&copy_file, $from_dir);
> 
> sub copy_file {
>    if (/\.c/) {

You need to anchor that pattern.


>       print "$File::Find::name\n";
>       $found_count++;
>       copy ($File::Find::name, "$to_dir/$_") or warn "Cannot copy 
> '$File::Find::name' $!";
>    }
> }
> 
> I ended up with temp/a.c but not b.c and c.c


John
-- 
use Perl;
program
fulfillment

-- 
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