in reply to Is this a severe error?

Quite often, this type of warning does not prevent you from getting the correct results. For example, it may be due to a file having an empty line at the bottom. You get this warning when you try to split the line and don't get the expected fields. This happens quite commonly. And you probably don't really care that much, your program works nonetheless.

But if you have it, it probably means that you are not inspecting your data close enough before using it. Although I might probably not care in a one-off one-liner, I would never leave such a warning in actual production code, even if the results are OK. Check your data before you use it, make sure it looks like what you expect, and raise an exception (or a warning) if it does not fit the bill.

Perl's strict and warnings pragmas, among others, help you writing more correct software, take advantage of it, don't hide the dust under the carpet.

Having said that, there are a very few cases where you might want to silence out some warnings. You can do that, if you really know what you're doing. There is at least one case where I remember having done it: the "deep recursion" warning tells you that you have entered more than 100 recursion levels. Sometimes it's OK if you have another way of controlling that the depth of recursion is not going run amok. But you really have to know damn well what you are doing. Judging from your question, you are not at that point yet.

Replies are listed 'Best First'.
Re^2: Is this a severe error?
by Anonymous Monk on Jun 04, 2015 at 17:14 UTC
    Dear Monks!
    Thanks A LOT for all these posts... I looked in the code and, before all these, I have written:
    my ($initial_label, $barrel_region, $start_of_barrel_region, $length_o +f_barrel_region);

    Wouldn't this "secure" that the $start_of_barrel_region is defined? Should I write something else?
      Wouldn't this "secure" that the $start_of_barrel_region is defined?
      No, as you can easily verify:
      #! /usr/bin/perl use warnings; use strict; my $x; print defined($x) ? "Defined\n" : "Undefined\n"; print $x;

      my declares a variable, but doesn't make it defined. You have to assign a value to it (other than undef) to make it defined.

      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      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.

        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?