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

File::Find changes the cwd, so you'll need to cache that using Cwd in order to avoid trying to copy a file over itself

#!/usr/bin/perl -w use strict; use warnings; use Cwd qw(getcwd); use File::Copy; use File::Find; my $dir = shift; print "$dir\n"; my $cwd = getcwd; my %files = map {$_ => 1} qw(data.txt datascript.pl); find(sub { copy($File::Find::name, $cwd) or die "Can't cp $File::Find::name: +$!" if (delete $files{$_}); }, $dir);