troubleshooting Question

Why am i getting "Use of uninitialized value $bo_plus in substitution (s///)

Avatar of Sandwick
Sandwick asked on
PerlScripting LanguagesRuby
14 Comments1 Solution773 ViewsLast Modified:
this script pick up a file and steps through it, and then picks up another file and matches the item number to merge the file and i getting this error, and I do not know why ?

here is the code where the file is blowing up with the following errors repeatedly.

<Error>
substr outside of string at ./parseOsc.pl line 272, <PLUS> line 745800.
substr outside of string at ./parseOsc.pl line 273, <PLUS> line 745800.
Use of uninitialized value $bo_plus in substitution (s///) at ./parseOsc.pl line 283, <PLUS> line 745800.
Use of uninitialized value $res_plus in substitution (s///) at ./parseOsc.pl line 284, <PLUS> line 745800.
Use of uninitialized value $res_plus in string eq at ./parseOsc.pl line 286, <PLUS> line 745800.
Use of uninitialized value $bo_plus in string eq at ./parseOsc.pl line 287, <PLUS> line 745800.
</Error>

<code>
while(<PLUS>) {
     $the_plus = $_;
     chomp($the_plus);
 
     $item_plus = substr($the_plus, 0,10);
     $bo_plus   = substr($the_plus,36, 5);
     $res_plus  = substr($the_plus,41, 5);

   next if $item_plus =~ m/\s*MSC/i;
 
     $item_plus =~ s/\s+//;
     next if $item_plus eq "";
 
   #print " $item  >$item_plus< \t $bo_plus  \t $res_plus \n";
 
   $bo_plus  =~ s/\s+//; ### Error happens here !!!
   $res_plus =~ s/\s+//; ### Error happens here !!!


         $res_plus = ($res_plus eq "" ) ? '0' : $res_plus;
        $bo_plus = ($bo_plus eq "" ) ? '0' : $bo_plus;
 
        next if ( $item ne $item_plus);

     if ( $item eq $item_plus ) {
        #$comingSoon = (( $onhand + $transit) - ( $res_plus + $bo_plus ));
        $comingSoon = (($transit) - ( $res_plus + $bo_plus ));
        if ( $comingSoon > 0 ) {
           $csoon = "Available < 35 days (" . $comingSoon .")";
        } else { $csoon = ""; }
        #  print "$comingSoon \t $onhand \t $transit \t $res_plus \t $bo_plus \n";  
     }
   }
 
Any Help would be appreciated !
thanks in advance
ASKER CERTIFIED SOLUTION
tel2

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 14 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 14 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros