Link to home
Start Free TrialLog in
Avatar of KFFrench
KFFrench

asked on

Use of Uninitialized Value at numeric

I was hoping that someone could take a minute and look at the quasi – finished script below and give me some pointers on a couple of things. Currently, the directory search for the files works, but it also returns “.” and “..” to the array which really messing things up for the rest of the script b/c “.” and “..” are obviously not filenames that data can't be pulled from. I’ve had to comment out this section and hard code the $filename variable for now to get it to run. The critical errors are when the script starts the conditional testing loop and the message I get is: “Use of uninitialized value in numeric gt (>) at J:\Documents\New Scheduling Script.pl line 85” and “Can't modify non-lvalue subroutine call at J:\Documents\New Scheduling Script.pl line 117.” I have tried replacing the conditional operater e.g.” >” with neq, but I still get the same error. Again if someone could take a look at these areas and let me know when or how I went wrong I would be very appreciative.


#!/usr/bin/perl -w

use strict;

use Win32::OLE qw(in with);

use Win32::OLE::Const 'Microsoft Excel';

use Win32::OLE::Variant;

use Win32::OLE::NLS qw(:LOCALE :DATE);

use Win32::OLE::NLS qw(:LOCALE :TIME);

use Win32::File;

use Data::Dumper;

$Win32::OLE::Warn = 3;

use utf8;

 

 

#my $rowNumber = 1;

my $filename = "C:\\Test\\Test_Cases2";

#my @listofFiles;

#

#chdir ('C:\Test');

#opendir(Dir, ".") or die;

#while ($filename = readdir Dir){

#    next if $filename =~m/^DNE/i;

#    push @listofFiles, $filename;

#}

#closedir Dir;

#

our (%output, %tmphash, $reference, $currentOutputRow, $OutputSheet);

#

#foreach my $filename (@listofFiles){

#    print Dumper @listofFiles;

   

my $Excel = Win32::OLE->GetActiveObject('Excel.Application')||

            Win32::OLE->new('Excel.Application', 'Quit');

my $book = $Excel->workbooks->open($filename);

my $sheet = $book->worksheets("Weekly_Snapshot");

 

for my $rowNumber (1..99999){

   

    #Read the current Row of data from the spreadhsheet.

   

    my $ID = $sheet->Range("A".$rowNumber)->{'Value'};

    my $ED = $sheet->Range("B".$rowNumber)->{'Value'};

    my $PL = $sheet->Range("C".$rowNumber)->{'Value'};

    my $RG = $sheet->Range("D".$rowNumber)->{'Value'};

    my $CT = $sheet->Range("E".$rowNumber)->{'Value'};

    my $IL = $sheet->Range("F".$rowNumber)->{'Value'};

    my $IS = $sheet->Range("G".$rowNumber)->{'Value'};

    my $CS = $sheet->Range("H".$rowNumber)->{'Value'};

    my $RDF = $sheet->Range("I".$rowNumber)->{'Value'};

    my $RDT = $sheet->Range("J".$rowNumber)->{'Value'};

    my $CM = $sheet->Range("K".$rowNumber)->{'Value'};

    my $SO = $sheet->Range("L".$rowNumber)->{'Value'};

    my $LI = $sheet->Range("M".$rowNumber)->{'Value'};

    my $AC = $sheet->Range("N".$rowNumber)->{'Value'};

    my $CD = $sheet->Range("O".$rowNumber)->{'Value'};

    my $NW = $sheet->Range("P".$rowNumber)->{'Value'};

    my $SL = $sheet->Range("Q".$rowNumber)->{'Value'};

    my $WH = $sheet->Range("R".$rowNumber)->{'Value'};

    my $QT = $sheet->Range("S".$rowNumber)->{'Value'};

    my $SQT = $sheet->Range("T".$rowNumber)->{'Value'};

    my $OP = $sheet->Range("U".$rowNumber)->{'Value'};

    my $CR = $sheet->Range("V".$rowNumber)->{'Value'};

    my $REQS = $sheet->Range("W".$rowNumber)->{'Value'};

    my $CRB = $sheet->Range("X".$rowNumber)->{'Value'};

    my $REQ = $sheet->Range("Y".$rowNumber)->{'Value'};

    my $MOD = $sheet->Range("Z".$rowNumber)->{'Value'};

    my $MODB = $sheet->Range("AA".$rowNumber)->{'Value'};

    my $TMAD = $sheet->Range("AB".$rowNumber)->{'Value'};

    my $CRD = $sheet->Range("AC".$rowNumber)->{'Value'};

    my $RSUB = $sheet->Range("AD".$rowNumber)->{'Value'};

    my $SCH = $sheet->Range("AE".$rowNumber)->{'Value'};

 

    my $compoundkey = "$ID-$SO-$LI";

    print Dumper $compoundkey;

    last if $compoundkey eq '--';

   

    #Condtional Testing

 

    if ($MOD > $output{$compoundkey}->{MOD}){                                                                          <<<<<critcal error

    delete ($output{$compoundkey});

    }

#    if ($MOD > $output{$compoundkey}->{$MOD} && $output{$compoundkey}->{$ID}!= {$ID}){

#    delete ($output{$compoundkey});

#    if ($MOD > $output{$compoundkey}->{$MOD} && $output{$compoundkey}->{$ID}!= {$ID}){

#    delete ($output{$compoundkey});

#    if ($MOD > $output{$compoundkey}->{$MOD} && $output{$compoundkey}->{$ID}!= {$ID}

#    && $output{$compoundkey}->{$ED, $PL, $RG, $CT, $IL, $IS, $CS, $RDF, $RDT, $CM, $AC,

#                                $CD, $NW, $SL, $WH, $SQT, $OP, $REQS, $CRB, $REQ, $MODB,

#                                $TMAD->Date(DATE_SHORTDATE), $CRD->Date(DATE_SHORTDATE),

#                                $RSUB, $SCH}!= {$ED, $PL, $RG, $CT, $IL, $IS, $CS, $RDF, $RDT, $CM, $AC,

#                                $CD, $SL, $WH, $SQT, $OP, $REQS, $CRB, $REQ, $MODB,

#                                $TMAD->Date(DATE_SHORTDATE), $CRD->Date(DATE_SHORTDATE), $RSUB, $SCH}){

#                                delete ($output{$compoundkey});

 

    next if $output{$compoundkey};

 

    $output{$compoundkey} = {ID => $ID, SO => $SO, LI => $LI, QT => $QT,

                            CR => $CR, MOD => $MOD, ED => $ED, PL => $PL,

                            RG => $RG, CT => $CT, IL => $IL, IS => $IS,

                            CS => $CS, RDF => $RDF, RDT =>$RDT, CM => $CM,

                            AC => $AC, CD => $CD, NW => $NW, SL => $SL,

                            WH => $WH, SQT => $SQT, OP => $OP, REQS => $REQS,

                            CRB => $CRB, REQ => $REQ, MODB => $MODB, TMAD => $TMAD,

                            CRD => $CRD, RSUB => $RSUB, SCH => $SCH};

#    

    my $outputSheet = $book->worksheets('Keepers');                                                        <<<<<2nd critical error

    my $currentOutputRow =1;

    my $numofOutputRows = keys(%output);

#

    for my $compoundkeys (keys(%output)){

            $outputSheet->Row("A$currentOutputRow") = $output{$compoundkey}->{$ID};

            $outputSheet->Row("B$currentOutputRow") = $output{$compoundkey}->{$SO};

            $outputSheet->Row("C$currentOutputRow") = $output{$compoundkey}->{$LI};

            $outputSheet->Row("D$currentOutputRow") = $output{$compoundkey}->{$QT};

            $outputSheet->Row("E$currentOutputRow") = $output{$compoundkey}->{$CR};

            $outputSheet->Row("F$currentOutputRow") = $output{$compoundkey}->{$MOD};

            $outputSheet->Row("G$currentOutputRow") = $output{$compoundkey}->{$ED};

            $outputSheet->Row("H$currentOutputRow") = $output{$compoundkey}->{$PL};

            $outputSheet->Row("I$currentOutputRow") = $output{$compoundkey}->{$RG};

            $outputSheet->Row("J$currentOutputRow") = $output{$compoundkey}->{$CT};

            $outputSheet->Row("K$currentOutputRow") = $output{$compoundkey}->{$IL};

            $outputSheet->Row("L$currentOutputRow") = $output{$compoundkey}->{$IS};

            $outputSheet->Row("M$currentOutputRow") = $output{$compoundkey}->{$CS};

            $outputSheet->Row("N$currentOutputRow") = $output{$compoundkey}->{$RDF};

            $outputSheet->Row("O$currentOutputRow") = $output{$compoundkey}->{$RDT};

            $outputSheet->Row("P$currentOutputRow") = $output{$compoundkey}->{$CM};

            $outputSheet->Row("Q$currentOutputRow") = $output{$compoundkey}->{$AC};

            $outputSheet->Row("R$currentOutputRow") = $output{$compoundkey}->{$CD};

            $outputSheet->Row("S$currentOutputRow") = $output{$compoundkey}->{$NW};

            $outputSheet->Row("T$currentOutputRow") = $output{$compoundkey}->{$SL};

            $outputSheet->Row("U$currentOutputRow") = $output{$compoundkey}->{$WH};

            $outputSheet->Row("V$currentOutputRow") = $output{$compoundkey}->{$SQT};

            $outputSheet->Row("W$currentOutputRow") = $output{$compoundkey}->{$OP};

            $outputSheet->Row("X$currentOutputRow") = $output{$compoundkey}->{$REQS};

            $outputSheet->Row("Y$currentOutputRow") = $output{$compoundkey}->{$CRB};

            $outputSheet->Row("Z$currentOutputRow") = $output{$compoundkey}->{$REQ};

            $outputSheet->Row("AA$currentOutputRow") = $output{$compoundkey}->{$MODB};

            $outputSheet->Row("AB$currentOutputRow") = $output{$compoundkey}->{$TMAD};

            $outputSheet->Row("AC$currentOutputRow") = $output{$compoundkey}->{$CRD};

            $outputSheet->Row("AD$currentOutputRow") = $output{$compoundkey}->{$RSUB};

            $outputSheet->Row("AE$currentOutputRow") = $output{$compoundkey}->{$SCH};

           

            $currentOutputRow++;

    }

    }
ASKER CERTIFIED SOLUTION
Avatar of Adam314
Adam314

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial