How do I solve this Perl Spreadsheet problem

This is in relation to the question I asked earlier.

http://www.experts-exchange.com/Programming/Languages/Scripting/Perl/Q_26409477.html

Now I am separating all the columns that need manual Matches into another tab in the excel sheet and not using that tab at all.

But after running the below code for the attached excel, getting this error after processing the entire sheet. What should I do?
==========================================

TEST PASSED.





The query is --


                  Select  E.POSTING_EVENT_TYPE_CDE, E.FUNDING_RULE_NME  from PFND.ETL_RULES E where E.POSTING_EVENT_TYPE_CDE = 'PBCLCASHPAY'.

Can't call method "value" on an undefined value at Verify_Col_Value1.pl line 91.
 at Verify_Col_Value1.pl line 30
        main::__ANON__('Can\'t call method "value" on an undefined value at Verify_Co...') called at Verify_Col_Value1.pl line 91



#!/ms/dist/perl5/bin/perl5.10 -w


use MSDW::Version
  'Spreadsheet-WriteExcel' => '2.35',
  'Spreadsheet-ParseExcel' => '0.57',
  'OLE-Storage_Lite'   => '0.19', # Used by Spreadsheet::WriteExcel
  'IO-stringy'         => '2.110',# IO::Scalar may be used by Spreadsheet::WriteExcel
  ;

use MSDW::Version ('DBD-DB2'   => '1.76-9.5.4', # or higher
                   'DBI'       => '1.609', # or higher
                   'DBD-MSDB2' => '1.6');

use warnings FATAL => qw(all);
use Spreadsheet::ParseExcel;
use Spreadsheet::ParseExcel::SaveParser;
use Spreadsheet::WriteExcel::Big;

use strict;
use IO::Scalar;
use Data::Dumper;
use DBI;
use DBD::MSDB2;
use File::Copy qw(cp);
use Carp;



$SIG{__DIE__} = sub { confess @_ };
$SIG{__WARN__} = sub { confess @_ };

my $posting_event_type = "PBCLCASHPAY";

#shift;

my $audit_funding_rule = "PB1";

#shift;
#"PBCLCASHPAY";
#shift;

my $col_fmt = "CCY";

#shift;
#"INPUT"; 

#shift;

#"INPUT";
my $ba_nid = 10180184;

#shift;
#shift; 
#11082557;
my $le_nid = 20000033;

#shift;
#20000050;
#shift;
#my @c_arr = ($ba_nid, $le_nid);
#11082557;

#my $sf = shift;
my $actual_file2 = "/v/region/na/appl/phoenixfunding/etl/data/qa/TgtFiles/delta_LibraPrimeBrokerage.txt";

#shift;

#"/v/region/na/appl/qatools/util/data/reports/SF/OtcTaxlotOpenDelta.txt";

#"/v/region/na/appl/qatools/util/data/reports/SF/OtcTaxlotOpenDelta.txt";
#shift

#my $cc1 = "BA_NID_VAL"; 
 
#shift;
#print "the ba-nid value in Verify Col script is $ba_nid\n"; 

my $sql_parser   = Spreadsheet::ParseExcel->new();
my $sql_workbook = $sql_parser->parse("Value_Type_Query.xls");
my $sql_worksheet = $sql_workbook->worksheet("Queries");

my ( $row_min, $row_max ) = $sql_worksheet->row_range();

for my $row ( $row_min+1 .. $row_max ) {

my $cell =  $sql_worksheet->get_cell($row, 0); 
#print $cell->value . "\n";


my $srl = $sql_worksheet->get_cell($row, 0)->value;
my $cc1 = $sql_worksheet->get_cell($row, 1)->value;
my $vt1 = $sql_worksheet->get_cell($row, 2)->value;
#my $flag =  $sql_worksheet->get_cell($row, 3)->value;

 if (defined $cell and $cell->value eq "$srl") {
   my $cell1 = $sql_worksheet->get_cell($row, 1);
   if (defined $cell1 and $cell1->value eq "$cc1") {
    
   my $cell2 = $sql_worksheet->get_cell($row, 2);
    if (defined $cell2 and $cell2->value eq "$vt1" and $cell2->value eq "$col_fmt" and  $sql_worksheet->get_cell($row, 3)->value eq "D" ) {
      my $query1 = $sql_worksheet->get_cell($row, 4)->value;

      $query1 =~ s/\$le_nid/$le_nid/;
      $query1 =~ s/\$ba_nid/$ba_nid/;
      $query1 =~ s/\$posting_event_type/$posting_event_type/;
      $query1 =~ s/\$audit_funding_rule/$audit_funding_rule/;

      print "\n\nThe First Final Query is --\n\n $query1\n\n";
      system("/ms/dist/perl5/bin/perl5.10", "/ms/user/s/sayantag/Finding_Act_Num2.pl", $query1, $actual_file2);  
        
          }
    elsif (defined $cell2 and $cell2->value eq "$vt1" and $cell2->value ne "NA" and $cell2->value ne "Manual Match Required" and $cell2->value eq "$col_fmt" and  $sql_worksheet->get_cell($row, 3)->value eq "H" ) 
         {my $query1 = $sql_worksheet->get_cell($row, 5)->value;
          print "\n\nThe Hard-coded value is --\n\n $query1\n\n";
         # system("/ms/dist/perl5/bin/perl5.10", "/ms/user/s/sayantag/Finding_Act_Num2.pl", $query1, $actual_file2);
          
         #########################################################################################################



    my @row;
   
    open(SF, $actual_file2) || die "Can't open $actual_file2: $!\n";
    my @data;

    while( <SF> ) {
    chomp;
    push @data, [split /\|/];

   }
   close(SF);

    push @row, $query1;    
    while (my @row) {
    foreach my $line (@data) {
     my $found = 0;
        foreach my $val (@row) {
            $found++ if grep({ $_ eq $val } @$line);

        }

        if ($found == @row)   {
            print "\n\nTEST PASSED.
                  \n\nAt the row ---\n\n
                  @$line
                  \n\nThe Value is --\n\n
                  $query1.\n\n";
        } else {
#            print "\n\nTEST FAILED .
#                  The Value is --
#                  $query1.\n\n";
        }
    }
}

         #########################################################################################################
           }

    elsif (defined $cell2  and $cell2->value eq "NA" and $sql_worksheet->get_cell($row, 3)->value eq "D" ) {
       ##############################################################################################
       my $query1 = $sql_worksheet->get_cell($row, 4)->value;

      $query1 =~ s/\$le_nid/$le_nid/;
      $query1 =~ s/\$ba_nid/$ba_nid/;
      $query1 =~ s/\$posting_event_type/$posting_event_type/;
      $query1 =~ s/\$audit_funding_rule/$audit_funding_rule/;

      print "\n\nThe Second Final Query is --\n\n $query1\n\n";
      system("/ms/dist/perl5/bin/perl5.10", "/ms/user/s/sayantag/Finding_Act_Num2.pl", $query1, $actual_file2);

       ############################################################################################

       }
    else {next;}
        }
       }
 
  
      }

Open in new window

Value-Type-Query.xls
sunny82Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

wilcoxonCommented:
Change line 91-93 to this:

my $srl = $sql_worksheet->get_cell($row, 0);
my $cc1 = $sql_worksheet->get_cell($row, 1);
my $vt1 = $sql_worksheet->get_cell($row, 2);
if (not defined $srl or not defined $cc1 or not defined $vt1) {
    warn "row $row has blanks in one or more of columns 0-2 - skipping";
    next;
}
$srl = $srl->value;
$cc1 = $cc1->value;
$vt1 = $vt1->value;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sunny82Author Commented:
Thx, it worked. I am closing this question and awarding points. If I have any further doubts tomorrow, I will ask you since, I will expand on more columns in the spreadsheet.

Thx again.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.