QM has asked for the wisdom of the Perl Monks concerning the following question:

I'm looking for a dictionary or encyclopedia of sorts for Perl error and warning messages. I searched for the following, didn't find much of use.
Use of uninitialized value in method with known name at blah.pl line 1 +23.

Yes, I understand what the issue is, I was just wondering what the extra verbage with in method with known name contributes? Are there methods with unknown names? Or is this perhaps a defensive/pro-active message, where the parser knew something about the context, and threw that in for free? I'm not against putting useful stuff in error messages, but this seems, to me at least, to distract from the real issue.

Here's an example of an offending line:

$self->{$Foo}{$Bar} = $self->{$Baz}{undef}->method;

(where undef is suitable replaced by an undefined $calar)

-QM
--
Quantum Mechanics: The dreams stuff is made of

Replies are listed 'Best First'.
Re: Perl Error Messages Explained?
by rjt (Curate) on Jul 09, 2013 at 11:25 UTC
    I'm looking for a dictionary or encyclopedia of sorts for Perl error and warning messages. I searched for the following, didn't find much of use.

    In short, perldiag, but in your programs, also:

    use diagnostics;

    The diagnostics pragma will expound upon any warning or error from Perl itself, with the text from perldiag.

    I was just wondering what the extra verbage with in method with known name contributes?

    Update

    Now that I'm back at my Perl build machine, I took a look at the opcode you mentioned. I think the AnonyMonk before me linked the most relevant source. As I understand it, the method_named is just a scratch placeholder for an identifier that Perl didn't bother to track (someone please correct me if I'm wrong), so the important part of this message is still the "uninitialized value", and you have a filename and line number, so you should be fine just acting on that as normal. If you think there's more to it, go ahead and post the method code and anything else that's relevant, and mark the error line for us somehow.

Re: Perl Error Messages Explained? (padop)
by Anonymous Monk on Jul 09, 2013 at 10:41 UTC
Re: Perl Error Messages Explained?
by dave_the_m (Monsignor) on Jul 09, 2013 at 14:49 UTC
    Use of uninitialized value
    Perl tried to use the value of a variable, and found that the value was undef, so it displayed a warning;
    in
    Since this generic warning can be triggered at any point during perl execution, perl tells you what opcode it was executing at the time; this gives a clue as to the likely culprit:
    method with known name
    The particular opcode is OP_METHOD_NAMED; the above is the textual description of that particular op. This op used when the method name is known at compile time, such as:
    $self->foo();
    as opposed to for example
    my $method = 'foo'; $self->$method();
    which uses OP_METHOD instead.

    Note that you won't get this particular warning from a simple $undefined_var->foo(), as perl will give you a specific warning in that case; so it's not clear to me how you're triggering that particular warning.

    Dave.

      This op used when the method name is known at compile time...

      Thanks, that's the nugget that failed to penetrate my noggin. The code line triggering this message,

      $self->{$Foo}{$Bar} = $self->{$Baz}{$undefined_scalar}->method;

      is syntactically the same as the real one (just the names changed to protect the guilty). I knew $undefined_scalar was the problem from the start, I just missed the hint about method names known at compile time versus those not known until run time. (Though I'm scratching my head to figure out when that wouldn't be patently obvious from the statement in question, but I suppose function references and other obscura can make for a hazy day.)

      At least my initial intuition was in the right direction...known at compile time is part of the context where the error/warning occurred.

      -QM
      --
      Quantum Mechanics: The dreams stuff is made of