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

I have the following simple eval block:
my $version; eval { $version = Object::Method($value); };
When I run it it throws this warning:
Use of uninitialized value in pattern match (m//) at (eval 65) line 4, + <> chunk 1
I am not sure where it is doing a pattern match since the Method of the object does not and nothing else is in the eval block. I am not sure where the line 4 and chunck 1 are referring to either since it is nowhere near line 4 in my code. Any ideas where to look?

Replies are listed 'Best First'.
Re: eval warnings
by ikegami (Patriarch) on Sep 28, 2005 at 21:06 UTC

    line 4 indicates the line on which the eval appears.

    eval 65 indicates the line of the string being evaluated on which the m// appears.

    Notice I said "of the string being evaluated". That means the eval causing the problem is one of the form eval EXPR, yet the one you showed is of the form eval BLOCK. The semantics of the two are very different.

    So the question you should be asking is: "Line 4 of which file?"

    <> chunk 1 indicates which line of the input file was being processed at the time. I'm not sure what causes this part of the message to appear, or what exactly does "input file" mean.

      So running it with the debugger the warning is a bit more useful:
      Use of uninitialized value in pattern match (m//) at (eval 67)[/usr/li +b/perl5/5.8.3/CGI.pm:773] line 4, <> chunk 1
      It seems the object I am calling requires a file that uses in another object that uses CGI is there a way I can disable warnings just aoround this code?