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

My script gets tons of errors like this...

Use of uninitialized value at gd2msl.pl line 41, <INFILE> chunk 1807.

The line has no uninitialized variables, and nothing whatever to do with reading from the file INFILE.
Any ideas?

Ben
  • Comment on NEWBIE: Can someone explain this error?

Replies are listed 'Best First'.
Re: NEWBIE: Can someone explain this error?
by chromatic (Archbishop) on Apr 20, 2000 at 22:58 UTC
    It means that, sometime after reading the 1807th record (chunk == record, or is that 'eq'?), there was an uninitialized value. Did you set $/ to something other than the default? If not, chunk == line of input file.

    My guess is that you have a:

    while (<INFILE>) { my $foo =~ s/blah/bar/; # anything goes here }
    in your code around line 41 that is choking on some input.
Re: NEWBIE: Can someone explain this error?
by markguy (Scribe) on Apr 20, 2000 at 23:24 UTC
    Posting of code is always a help. At least the loop that line is in and the source of the input.
    Could always turn of warnings, I suppose... that's a joke. Although I occasionally turn it off in local blocks when I know the warnings are trivial and it's time to move on. Funny thing is, it's amazing how often I shoot myself in the foot by *knowing* something :)
RE: NEWBIE: Can someone explain this error?
by Anonymous Monk on Apr 21, 2000 at 01:21 UTC
    A common cause is code like this: ($a, $b) = /foo(bar+)(baz*)/; $result = "got baz: $b"; or $result = "got baz: $1"; You may have a value that "should" be assigned but was instead undefined.