Perl, irrelevant error messages?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • STAGED
    New Member
    • Apr 2006
    • 6

    Perl, irrelevant error messages?

    NEWBIE ALERT...

    I have a script that renames filenames. It has some basic math operations associated with it too.

    The script ***runs perfectly*** in its intended task and all variables have values before operations occur on those variables. However I still get error messages (see below) complaining about uninitialized value which is untrue. Any idea why?
    ---------------
    Use of uninitialized value in division (/)...
    Use of uninitialized value in multiplication (*)...
    Last edited by STAGED; Apr 30 '06, 04:44 AM.
  • sethi
    New Member
    • Apr 2006
    • 2

    #2
    it 'll be better if u send ur script alongwith ur query.So that forum member will be able to reply u.

    Regards

    Sethi

    Comment

    • STAGED
      New Member
      • Apr 2006
      • 6

      #3
      O.K., here's a snipet:
      -----------------------
      $cfac = 1;
      for ($i=0;$i<=$coun tnpf;$i++) {
      $cfac = $A1[2][$i] / $maxfac;
      $A1[3][$i] = $A1[1][$i] * $cfac;
      } # end for loop
      ------------------------
      Facts:
      1.) @A1 and $maxfac are definied with values BEFORE going into this loop as outputted those values just before the loop as verification.
      2.) I get complaints: "Use of uninitialized value in division (/)..." and "Use of uninitialized value in multiplication (*)..."
      -----------------------
      Puzzling experiment
      1.) If for grins, I comment out the loop and did a sample calculation WITHOUT any looping, there are no error messages!!!

      Why is this calculation a problem inside the loop?

      Last but not least, the script with the functioning loop works as intended (filenames renamed properly based on the above math operations) albeit with these peculiar error messages.

      Thanks in advance...
      Last edited by STAGED; Apr 30 '06, 04:57 AM.

      Comment

      • STAGED
        New Member
        • Apr 2006
        • 6

        #4
        OK, I found the mistake on my own. By virtue of the loop increment variable, the condition to stop the loop should be "<" instead of "<=", otherwise the loop tries to excute one too many times.

        Comment

        Working...