#!/usr/bin/perl5.10
# -w is redundant with use warnings
use warnings;
use Spreadsheet::WriteExcel::Big;
use Spreadsheet::ParseExcel;
use strict;
use IO::Scalar;
use Data::Dumper;
use File::Copy qw(cp);
my $CFP = "/ms/user/s/sayantag/";
my $new_parser = Spreadsheet::ParseExcel->new();
my $new_workbook = $new_parser->parse($CFP . "Source.xls");
my $curr_etl = "wf_OTC_Taxlots_Open";
my $wf_name = substr $curr_etl, 3;
print "The workflow name is $wf_name\n";
for my $new_worksheet ( $new_workbook->worksheets() ) {
next unless $new_worksheet->{Name} eq "WF";
#print "xyb";
my ( $row_min, $row_max ) = $new_worksheet->row_range();
my ( $col_min, $col_max ) = $new_worksheet->col_range();
for my $row ( $row_min .. $row_max ) {##First for##
my $cell = $new_worksheet->get_cell($row, 0);
if (defined $cell and $cell->value eq $curr_etl) {
my $wf_loc = $new_worksheet->get_cell($row, 2)->value;
print "$wf_loc";
opendir DIR, $wf_loc
or die "could not open $wf_loc: $!";
my @delta_files = grep m{^delta_${wf_name}_Baseline\.txt$}, readdir DIR;
closedir DIR;
foreach my $txt_file (@delta_files) {
cp "$wf_loc/$txt_file" "$wf_loc/../Delta_ETL/$txt_file"
or die "could not cp $wf_loc/$txt_file: $!";
}
}
}
}
|