use Spreadsheet::ParseExcel; use File::Find; use File::Copy; my $oBook = Spreadsheet::ParseExcel::Workbook->Parse('regions.xls'); my($iR, $iC, $oWkS, $oWkC); my $dir = "D:\schema"; #for mapped drives give \\ and for local drives \ my $currentdir = $ARGV[0]; my @inputarray = (); my $count = -1; foreach my $oWkS (@{$oBook->{Worksheet}}) { for(my $iR = $oWkS->{MinRow} ; defined $oWkS->{MaxRow} && $iR <= $oWkS->{MaxRow} ; $iR++) { for(my $iC = $oWkS->{MinCol} ;defined $oWkS->{MaxCol} && $iC <= $oWkS->{MaxCol} ; $iC++) { $oWkC = $oWkS->{Cells}[$iR][$iC]; push(@inputarray,$oWkC->Value); } } } while ($#inputarray > 0) { find({ wanted => \&edits}, $dir); } sub edits() { if ( -f and /.xml?/ and $#inputarray >= 0) { $file = $_; print $#inputarray; foreach $input(@inputarray) { $count++; if ($#inputarray < 0) { print "Input array empty"; last; } if ($file =~ $input) { @newarraypreceding = splice (@inputarray,0,$count-1); @newarrayfollowing = splice (@inputarray,$count+1); @inputarray = (@newarraypreceding , @newarrayfollowing); print $input; print " popped out $input from array"; copy($file, $currentdir//$file) or die "File cannot be copied."; print "Array count : $#inputarray"; } } } }