Apologize for the long post. Need to resolve this error in the perl program
Here is the sample file
NAME ; M0511514944
CLASS ; DRAW
DATETIME ; 20050425104230
FROMBOXNO ; XYZA
FROMLOC ; XYZ
FROMPERSON ; Jane Doe
FROMEMAIL ; xyz@xyz.com
FROMPHONE ; 999-999-9999
TOBOXNO ; ABCDEF
TOCOMPANY ; ABC Inc.
TOPERSON ; John Doe
TOEMAIL ; abc@abc.com
SENDNOTIFICATION ; Y
SENDCTRLFILE ; Y
Here is the function that parses the file
sub GetControlInfo {
my $Cmd;
my $Log;
my $Name;
my $Class;
my $Aprf;
my $WkDir;
my $UniqId;
my $Sender;
my $Notifcn;
my $ErrFlag;
my $RetValue;
my @TmpStore;
my $TempFile;
my $Receiver;
my $CtrlFile;
my $SendCtrl;
my $SenderEmail;
my $ReceiverEmail;
($CtrlFile,$Name,$Sender,$Receiver,$Notifcn,$SendCtrl,$Log,$UniqId,$WkDir,$ErrFlag,$Aprf,$SenderEmail,$ReceiverEmail)=@_;
chdir "$WkDir" or die "${CtrlFile}:Error changing to the WorkDir $! \n";
#Run the staging script to update document status info for Drawings
$TempFile="/entH/temp/${CtrlFile}.tmp";
$Cmd = "/entH/bin/OBStagingDwg.sh $CtrlFile 2>&1 $Log \n";
$RetValue = system ("$Cmd");
if ($RetValue != 0)
{
rename "$WkDir$CtrlFile", "$WkDir${CtrlFile}.err";
$ErrFlag = 1;
$_[8] = $ErrFlag;
return 0;
}
open (TMPFILE, "$TempFile") or die ("Error opening the temp file to read Config File $! \n");
while (<TMPFILE>)
{
@TmpStore=$_;
}
$UniqId = splice (@TmpStore,0);
close (TMPFILE);
print "Value of Temp File is :- $TempFile \n";
unlink $TempFile;
open (CTRFILE, "$CtrlFile") or die (" Error opening the control file $! \n");
while (<CTRFILE>)
{
#Set the default values of
$Notifcn = "Y";
$SendCtrl = "Y";
if ( $_ =~ 'NAME' )
{
@TmpStore=split (';',$_);
$Sender=splice(@TmpStore,1);
#trim leading spaces and trailing spaces
$Name =~ s/^\s*(.*?)\s*$/$1/; # Line number 158 in original code
print "Value of Name is :- $Name \n";
}
if ( $_ =~ 'CLASS' )
{
@TmpStore=split (';',$_);
$Class=splice(@TmpStore,1);
#trim leading spaces and trailing spaces
$Class =~ s/^\s*(.*?)\s*$/$1/;
$Aprf = $1;
print "Value of Class is :- $Class \n";
print "Value of APRF is :- $Aprf \n";
}
if ( $_ =~ 'FROMBOXNO' )
{
@TmpStore=split (';',$_);
$Sender=splice(@TmpStore,1);
#trim leading spaces and trailing spaces
$Sender =~ s/^\s+//; chomp ($Sender);
print "Value of Sender is :- $Sender \n";
}
if ( $_ =~ 'TOBOXNO' )
{
@TmpStore=split (';',$_);
$Receiver=splice(@TmpStore,1);
#trim leading spaces and trailing spaces
$Receiver =~ s/^\s+//; chomp ($Receiver);
print "Value of Receiver is :- $Receiver \n";
}
if ( $_ =~ 'SENDNOTIFICATION' )
{
@TmpStore=split (';',$_);
$Notifcn=splice(@TmpStore,1);
#trim leading spaces and trailing spaces
$Notifcn =~ s/^\s+//; chomp ($Notifcn);
print "Value of Notification is :- $Notifcn \n";
}
if ( $_ =~ 'SENDCTRLFILE' )
{
@TmpStore=split (';',$_);
$SendCtrl=splice(@TmpStore,1);
#trim leading spaces and trailing spaces
$SendCtrl =~ s/^\s+//; chomp ($SendCtrl);
print "Value of Send Control File :- $SendCtrl \n";
}
if ( $_ =~ 'FROMEMAIL' )
{
@TmpStore=split (';',$_);
$SenderEmail=splice(@TmpStore,1);
$SenderEmail =~ s/^\s//; chomp($SenderEmail);
print "Value of Senders Email is :- $SenderEmail \n";
}
if ( $_ =~ 'TOEMAIL' )
{
@TmpStore=split (';',$_);
$ReceiverEmail=splice(@TmpStore,1);
$ReceiverEmail =~ s/^\s//; chomp($ReceiverEmail);
print "Value of Receivers Email is:- $ReceiverEmail \n";
}
}#End of while()
close (CTRFILE);
$_[1]=$Name;
$_[2]=$Sender;
$_[3]=$Receiver;
$_[4]=$Notifcn;
$_[5]=$SendCtrl;
$_[7]=$UniqId;
$_[9]=$ErrFlag;
$_[10]=$Aprf;
$_[11]=$SenderEmail;
$_[12]=$ReceiverEmail;
}#End of GetControlInfo
From the main program a call to the function GetControlInfo is placed as follows
GetControlInfo ($CtrFile, $Name, $Sender, $Receiver, $SendMail, $PostCtrl, $LogFile, $Snrf, $CurDir, $ErrFileFlag, $Aprf
, $SenderEmail, $ReceiverEmail);
When this function is called I get the warning/error message
Use of uninitialized value in substitution (s///) at test.pl line 158, <CTRFILE> line 1.
Use of uninitialized value in substitution (s///) at test.pl line 158, <CTRFILE> line 1.
How can this be overcome. Any help is much appreciated. Thanks.