in reply to read the whole folder files

It was running fine yesterday but today I keep getting a warning "use of uninitialised value ...in pattern match.. can anyone spot the mistake below?
if ($energy_consumption =~ /^[^0-1-.]/ or ( $energy_consumption < +60 or $energy_consumption > 120))

Replies are listed 'Best First'.
Re^2: read the whole folder files
by kennethk (Abbot) on Apr 10, 2012 at 18:08 UTC

    Well, the warning says there is an uninitialized value in a pattern match, so clearly that means that $energy_consumption is undefined when you get there. That value is assigned in your split, so therefore the split isn't outputting at least 8 values. I suspect that your input file is not formatted as your expect. A quick way to find the offending lines would be to add the block

    if (not defined $energy_consumption) { warn "Split missed, $file: $_"; next; }

    after the split, and see what comes out. My guess is that you are working with tab-delimited files, and there are some empty values.

    #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

      Hello, Thank you for your time..I added the block after split but it keeps warning me.. I checked the output of the tab-delim file aswell..Doesn't seem to be a problem there.. it just outputs something like the following
      split missed, myresultfile.txt: 61283067 61283865 798 0.57412
        The block was not intended to fix the warning; it was intended to point out how to find your issue. You have a line that contains "61283067  61283865  798  0.57412" that your split fails on. There are clearly only 4 entries on that line, not the 8 required to populate the variable in question. You need to modify your split (or perhaps swap to a regular expression) to reflect the actual input.

        #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.