in reply to Re^2: Is this a severe error?
in thread Is this a severe error?

No, defined is not the same thing as declared.

With your my (...); statement, you have properly declared these variables, but they are still not defined because you haven't assigned any value to them.

Update: Oops, choroba was faster than me.

Replies are listed 'Best First'.
Re^4: Is this a severe error?
by Anonymous Monk on Jun 04, 2015 at 18:06 UTC
    Ok, I did as told and got:
    $hash_plp_lbl_barrel_region_only{195} is undefined

    So there is no value for the hash if $s is equal to 195 I presume, right?
      Yes. This is most probably right.

      Note that you can check that with two possibly syntax:

      print "value undefined" unless defined $hash_plp_lbl_barrel_region_onl +y{$s};
      or
      print "key does not exist in hash" unless exists $hash_plp_lbl_barrel_ +region_only{$s};
      The difference between the two syntaxes is a bit subtle, but not so complicated.

      The variable $hash{foo} may have several status.

      If the element for key "foo" does not exist at all in the hash, both defined and exists will report a false value.

      If the element for key "foo" exists, but the value for that element is not defined, then exists will return a true value, and defined will report false.

      I hope this is clear, as I said this is somewhat subtle, but it is important in some cases to understand the difference.

      Having said that, it is often not so important, the difference is in many case inexistent, it really depends on how you hash was built in the first place (and how you maintain it).

      Well, I hope my explanations are clear, if they are not, please ask, may be an example might be clearer.

        I printed all positions and realized my mistake, there was no value for the key of 195...
        In any case, I wish to thank all of you for your time and tips, it is really helpful to read up on this advice!