#!/usr/bin/perl -w use strict; use File::Copy; do_copy("path/to/dir","path/to/dest"); exit(0); sub do_copy { my ($src_path,$dest_path)=@_; opendir(DIR,$src_path) or die "$src_path: $!"; while(my $entry=readdir(DIR)){ next if $entry eq '..'; next if $entry eq '.'; my $sfqp = $src_path . "/" . $entry; my $dfqp = $dest_path . "/" . $entry; if ( -d $sfqp ) { mkdir $dfq,0755; # Change to your mask do_copy($sfqp,$dfqp); # Recursion } elsif ( -f $sfqp ) { copy $sfqp,$dfqp or die $! } } }