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

Hi,

I'm getting a very strange error:

Uncaught exception from user code: Did not find leading dereferencer, detected at offset 8231.

Its very frustrating because it's not relating it to a specific line of code and I have 8000 lines of code in my Perl module. Often I can use my Perl module find but then when I put in a simple print statement in I get the error. Could you tell me what type of things cause this error?

I used to use prototypes but I took those out. Instead in subroutines I dereference as @{ $_[0] ) when I'm expecting an array as one of my arguments and @_ when an array is the only argument. I use my $hash = $_[i] when a hash is passed as the only or one of the arguments. I store references to arrays as $array[$i] = \@array.

Any ideas?

Cheers,

Sean

Replies are listed 'Best First'.
Re: Did not find leading dereferencer, detected at offset 8231
by BrowserUk (Patriarch) on Sep 16, 2006 at 11:09 UTC

    Are you using Text::Balanced by any chance?


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      No I'm not. I did see lots on the Net about it. The annoying thing is that I'm using strict and even when I purposely dereference something that is not a reference I don't get a strict error - i.e. my %hash = (); $hash{key} = $value; print $$hash{key} does not give me an error saying the hash is not defined I get the dereferencing error but I get this error when I have got everything working and then I put in a print statement. Do you know how I can avoid this error when using references?

        The error message you posted is not a standard Perl warning or error. Therefore, the cause of the message is not a direct result of your code. It originates from Text::Balanced, and if you are not using that module directly, then you must be using a module that uses that module (like Parse::RecDescent or similar).

        It is impossible to advise you how to correct your code, without seeing the code, but I would not suggest you post your 3000 lines here, so you are going to have to do some detective work and come up with a few lines of code that produce the same error. If you haven't solved it by the time you have reduce your code to < 30 lines, then post the lines that produce the problem and someone will be able to help you.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
Re: Did not find leading dereferencer, detected at offset 8231
by graff (Chancellor) on Sep 16, 2006 at 15:59 UTC
    I have to say, your post is pretty incoherent. Consider that last sentence of yours (with <code> tags added where they are needed):
    I store references to arrays as $array[$i] = \@array.
    Do you really mean that you have a line of code like that, where the same array name is used on both the left and right sides of the assignment? That sets the "$i'th" element of @array to be a reference to @array. Why would you do something like that? If you aren't doing that, then what are you really doing?

    And the sentence before that:

    I use my $hash = $_[i] when a hash is passed as the only or one of the arguments.
    Okay, I'll assume that the missing "$" sigil for "i" is just a typo there. But then, how do you call the subroutine that contains that line, and how do you use $hash within that subroutine? Those issues are just as important.

    Maybe the code you are actually trying to run does not contain the silly errors in your post -- it would be better if you showed us at least some of the actual code.

    Have you ever heard about the perl debugger? Check the man page called perldebug, and try running your script like this:

    perl -d your_script
    (If the script takes command-line args, just include those as you normally would, after the name of the script file.) Then do things like setting break points, stepping through portions of the code, inspecting values of variables as you go, etc.

    Also, if you have not done so yet, add "use Data::Dumper;" to your script. That way, when you run it with the debugger, you can do things like:

    print Dumper( $some_ref_variable )
    as commands to the debugger itself, to see whether the references are working and the data structures are coming out the way you expect them to.
Re: Did not find leading dereferencer, detected at offset 8231
by Anonymous Monk on Sep 17, 2006 at 11:33 UTC
    use Devel::Trace, and figure out where the message is coming from.
Re: Did not find leading dereferencer, detected at offset 8231
by Khen1950fx (Canon) on Sep 16, 2006 at 22:38 UTC
    FYI: I've been googling your question, and I haven't been able to find anything about offset 8231, at least in Perl. I did get some info about 8231 on the Microsoft site. According to the Win site that I was on, offset 8231 is:

    offset 8231 the requested authentication method is not supported by the server

    Are you on Windows? I can't tell, so you need to be more precise. I would change course here and take the advice in the previous replies to heart. Use Text::Balanced as a starting point.

      The "8231" part is bound to be a value that depends on the particular data being given to the script (that is, it refers to the offset from the beginning of a string or file). The part you want to google for is "Did not find leading dereferencer, detected at offset".

      When I put that in the search box, the first significant (informative) hit turned out to be the source code for Text::Balanced. So that's where the particular message came from. (It's unlikely that another module would use the exact same wording.)