sub copy_recursively { my ($from_dir,$to_dir) = @_; opendir(DIR, $from_dir) or die "Could not open dir '$from_dir': $!"; my @dir = readdir(DIR); for(my $j=2 ; $j <= $#dir; $j++){ my $source = "$from_dir/$dir[$j]"; my $destination = "$to_dir/$dir[$j]"; next if($dir[$j] eq "." || $dir[$j] eq ".."); if (-d $source) { print LOG "The source and destination in the directory section :-\n $source and $destination\n"; mkdir($destination,"0777") or die "mkdir '$destination' failed: $!" if not -e $destination; copy_recursively($source, $destination); } else { print LOG "The source and destination in the File section :-\n $source and $destination\n"; open(FILE,"<", $source); my @file_content = ; close(FILE); for(my $u=0;$u<=$#file_content;$u++) { $file_content[$u] = s/logo-$source_branch/logo-$cloneName/g ; print LOG "$file_content[$u]"; } open(FILEOUT,">", $destination); for(my $v=0;$v<=$#file_content;$v++) { print FILEOUT "$file_content[$v]"; }