Hi ALL,
I'm trying to write a script which will retrieve all the files whose names are present in an excel. I'm using an array to get all the entries present in the excel and splicing the input array when i find a match for a particular entry in the array. But an infinite loop is running even after all the files are fetched. And also the process is very slow when i try to retrieve files from directories that have huge datas in it. So help me out in ending the loop and also in speeding up the process.
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 , @newar
+rayfollowing);
print $input; print " popped out $input fr
+om array";
copy($file, $currentdir//$file) or die "Fi
+le cannot be copied.";
print "Array count : $#inputarray";
}
}
}
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.