#!/usr/bin/perl -w use strict; use File::Copy; my $from = "/root/yim"; my $to = "/root/perl/yim"; if ( -d $from ) { mkdir "$to"; } opendir(DIR,"$from"); my @contents = readdir(DIR); for my $i(@contents) { if ( -f "$from/$i" ) { copy("$from/$i","$to/$i"); } } close(DIR); print @contents;