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->GetActiveObjec t('Excel.A pplication ')||
Win32::OLE->new('Excel.App lication', 'Quit');
my $book = $Excel->workbooks->open($f ilename);
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".$rowNumb er)->{'Val ue'};
my $ED = $sheet->Range("B".$rowNumb er)->{'Val ue'};
my $PL = $sheet->Range("C".$rowNumb er)->{'Val ue'};
my $RG = $sheet->Range("D".$rowNumb er)->{'Val ue'};
my $CT = $sheet->Range("E".$rowNumb er)->{'Val ue'};
my $IL = $sheet->Range("F".$rowNumb er)->{'Val ue'};
my $IS = $sheet->Range("G".$rowNumb er)->{'Val ue'};
my $CS = $sheet->Range("H".$rowNumb er)->{'Val ue'};
my $RDF = $sheet->Range("I".$rowNumb er)->{'Val ue'};
my $RDT = $sheet->Range("J".$rowNumb er)->{'Val ue'};
my $CM = $sheet->Range("K".$rowNumb er)->{'Val ue'};
my $SO = $sheet->Range("L".$rowNumb er)->{'Val ue'};
my $LI = $sheet->Range("M".$rowNumb er)->{'Val ue'};
my $AC = $sheet->Range("N".$rowNumb er)->{'Val ue'};
my $CD = $sheet->Range("O".$rowNumb er)->{'Val ue'};
my $NW = $sheet->Range("P".$rowNumb er)->{'Val ue'};
my $SL = $sheet->Range("Q".$rowNumb er)->{'Val ue'};
my $WH = $sheet->Range("R".$rowNumb er)->{'Val ue'};
my $QT = $sheet->Range("S".$rowNumb er)->{'Val ue'};
my $SQT = $sheet->Range("T".$rowNumb er)->{'Val ue'};
my $OP = $sheet->Range("U".$rowNumb er)->{'Val ue'};
my $CR = $sheet->Range("V".$rowNumb er)->{'Val ue'};
my $REQS = $sheet->Range("W".$rowNumb er)->{'Val ue'};
my $CRB = $sheet->Range("X".$rowNumb er)->{'Val ue'};
my $REQ = $sheet->Range("Y".$rowNumb er)->{'Val ue'};
my $MOD = $sheet->Range("Z".$rowNumb er)->{'Val ue'};
my $MODB = $sheet->Range("AA".$rowNum ber)->{'Va lue'};
my $TMAD = $sheet->Range("AB".$rowNum ber)->{'Va lue'};
my $CRD = $sheet->Range("AC".$rowNum ber)->{'Va lue'};
my $RSUB = $sheet->Range("AD".$rowNum ber)->{'Va lue'};
my $SCH = $sheet->Range("AE".$rowNum ber)->{'Va lue'};
my $compoundkey = "$ID-$SO-$LI";
print Dumper $compoundkey;
last if $compoundkey eq '--';
#Condtional Testing
if ($MOD > $output{$compoundkey}->{MO D}){ <<<<<critcal error
delete ($output{$compoundkey});
}
# if ($MOD > $output{$compoundkey}->{$M OD} && $output{$compoundkey}->{$I D}!= {$ID}){
# delete ($output{$compoundkey});
# if ($MOD > $output{$compoundkey}->{$M OD} && $output{$compoundkey}->{$I D}!= {$ID}){
# delete ($output{$compoundkey});
# if ($MOD > $output{$compoundkey}->{$M OD} && $output{$compoundkey}->{$I D}!= {$ID}
# && $output{$compoundkey}->{$E D, $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$curre ntOutputRo w") = $output{$compoundkey}->{$I D};
$outputSheet->Row("B$curre ntOutputRo w") = $output{$compoundkey}->{$S O};
$outputSheet->Row("C$curre ntOutputRo w") = $output{$compoundkey}->{$L I};
$outputSheet->Row("D$curre ntOutputRo w") = $output{$compoundkey}->{$Q T};
$outputSheet->Row("E$curre ntOutputRo w") = $output{$compoundkey}->{$C R};
$outputSheet->Row("F$curre ntOutputRo w") = $output{$compoundkey}->{$M OD};
$outputSheet->Row("G$curre ntOutputRo w") = $output{$compoundkey}->{$E D};
$outputSheet->Row("H$curre ntOutputRo w") = $output{$compoundkey}->{$P L};
$outputSheet->Row("I$curre ntOutputRo w") = $output{$compoundkey}->{$R G};
$outputSheet->Row("J$curre ntOutputRo w") = $output{$compoundkey}->{$C T};
$outputSheet->Row("K$curre ntOutputRo w") = $output{$compoundkey}->{$I L};
$outputSheet->Row("L$curre ntOutputRo w") = $output{$compoundkey}->{$I S};
$outputSheet->Row("M$curre ntOutputRo w") = $output{$compoundkey}->{$C S};
$outputSheet->Row("N$curre ntOutputRo w") = $output{$compoundkey}->{$R DF};
$outputSheet->Row("O$curre ntOutputRo w") = $output{$compoundkey}->{$R DT};
$outputSheet->Row("P$curre ntOutputRo w") = $output{$compoundkey}->{$C M};
$outputSheet->Row("Q$curre ntOutputRo w") = $output{$compoundkey}->{$A C};
$outputSheet->Row("R$curre ntOutputRo w") = $output{$compoundkey}->{$C D};
$outputSheet->Row("S$curre ntOutputRo w") = $output{$compoundkey}->{$N W};
$outputSheet->Row("T$curre ntOutputRo w") = $output{$compoundkey}->{$S L};
$outputSheet->Row("U$curre ntOutputRo w") = $output{$compoundkey}->{$W H};
$outputSheet->Row("V$curre ntOutputRo w") = $output{$compoundkey}->{$S QT};
$outputSheet->Row("W$curre ntOutputRo w") = $output{$compoundkey}->{$O P};
$outputSheet->Row("X$curre ntOutputRo w") = $output{$compoundkey}->{$R EQS};
$outputSheet->Row("Y$curre ntOutputRo w") = $output{$compoundkey}->{$C RB};
$outputSheet->Row("Z$curre ntOutputRo w") = $output{$compoundkey}->{$R EQ};
$outputSheet->Row("AA$curr entOutputR ow") = $output{$compoundkey}->{$M ODB};
$outputSheet->Row("AB$curr entOutputR ow") = $output{$compoundkey}->{$T MAD};
$outputSheet->Row("AC$curr entOutputR ow") = $output{$compoundkey}->{$C RD};
$outputSheet->Row("AD$curr entOutputR ow") = $output{$compoundkey}->{$R SUB};
$outputSheet->Row("AE$curr entOutputR ow") = $output{$compoundkey}->{$S CH};
$currentOutputRow++;
}
}
#!/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->GetActiveObjec
Win32::OLE->new('Excel.App
my $book = $Excel->workbooks->open($f
my $sheet = $book->worksheets("Weekly_
for my $rowNumber (1..99999){
#Read the current Row of data from the spreadhsheet.
my $ID = $sheet->Range("A".$rowNumb
my $ED = $sheet->Range("B".$rowNumb
my $PL = $sheet->Range("C".$rowNumb
my $RG = $sheet->Range("D".$rowNumb
my $CT = $sheet->Range("E".$rowNumb
my $IL = $sheet->Range("F".$rowNumb
my $IS = $sheet->Range("G".$rowNumb
my $CS = $sheet->Range("H".$rowNumb
my $RDF = $sheet->Range("I".$rowNumb
my $RDT = $sheet->Range("J".$rowNumb
my $CM = $sheet->Range("K".$rowNumb
my $SO = $sheet->Range("L".$rowNumb
my $LI = $sheet->Range("M".$rowNumb
my $AC = $sheet->Range("N".$rowNumb
my $CD = $sheet->Range("O".$rowNumb
my $NW = $sheet->Range("P".$rowNumb
my $SL = $sheet->Range("Q".$rowNumb
my $WH = $sheet->Range("R".$rowNumb
my $QT = $sheet->Range("S".$rowNumb
my $SQT = $sheet->Range("T".$rowNumb
my $OP = $sheet->Range("U".$rowNumb
my $CR = $sheet->Range("V".$rowNumb
my $REQS = $sheet->Range("W".$rowNumb
my $CRB = $sheet->Range("X".$rowNumb
my $REQ = $sheet->Range("Y".$rowNumb
my $MOD = $sheet->Range("Z".$rowNumb
my $MODB = $sheet->Range("AA".$rowNum
my $TMAD = $sheet->Range("AB".$rowNum
my $CRD = $sheet->Range("AC".$rowNum
my $RSUB = $sheet->Range("AD".$rowNum
my $SCH = $sheet->Range("AE".$rowNum
my $compoundkey = "$ID-$SO-$LI";
print Dumper $compoundkey;
last if $compoundkey eq '--';
#Condtional Testing
if ($MOD > $output{$compoundkey}->{MO
delete ($output{$compoundkey});
}
# if ($MOD > $output{$compoundkey}->{$M
# delete ($output{$compoundkey});
# if ($MOD > $output{$compoundkey}->{$M
# delete ($output{$compoundkey});
# if ($MOD > $output{$compoundkey}->{$M
# && $output{$compoundkey}->{$E
# $CD, $NW, $SL, $WH, $SQT, $OP, $REQS, $CRB, $REQ, $MODB,
# $TMAD->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
# 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
my $currentOutputRow =1;
my $numofOutputRows = keys(%output);
#
for my $compoundkeys (keys(%output)){
$outputSheet->Row("A$curre
$outputSheet->Row("B$curre
$outputSheet->Row("C$curre
$outputSheet->Row("D$curre
$outputSheet->Row("E$curre
$outputSheet->Row("F$curre
$outputSheet->Row("G$curre
$outputSheet->Row("H$curre
$outputSheet->Row("I$curre
$outputSheet->Row("J$curre
$outputSheet->Row("K$curre
$outputSheet->Row("L$curre
$outputSheet->Row("M$curre
$outputSheet->Row("N$curre
$outputSheet->Row("O$curre
$outputSheet->Row("P$curre
$outputSheet->Row("Q$curre
$outputSheet->Row("R$curre
$outputSheet->Row("S$curre
$outputSheet->Row("T$curre
$outputSheet->Row("U$curre
$outputSheet->Row("V$curre
$outputSheet->Row("W$curre
$outputSheet->Row("X$curre
$outputSheet->Row("Y$curre
$outputSheet->Row("Z$curre
$outputSheet->Row("AA$curr
$outputSheet->Row("AB$curr
$outputSheet->Row("AC$curr
$outputSheet->Row("AD$curr
$outputSheet->Row("AE$curr
$currentOutputRow++;
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.