in reply to How do I find the missing curly brace??

maybe the fastest possibility to find such a bug without knowing the last healthy state:

I tried this with a 30k lines module and the output had 5k lines.

you'll get something like this which is easier to be checked visually:

One extra hint: since nesting subs is rare in Perl I'd also grep for sub keywords which are (unusually) intended.

That's only 600 lines in this case.

Apply perltidy -csci=0 -csc for "closing side comments" everywhere to identify the closing } of sub, if, etc.

Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^2: How do I find the missing curly brace??
by perlfan (Parson) on Dec 31, 2024 at 08:53 UTC
    perltidy is a good suggestion. Similarly, vim or some other editor that does highlighting or highlights the start/end of the current BLOCK, might be useful. I wonder if perlcritic would similarly be useful? And maybe as a final stab, perl -c.
      perl -c will just reproduce the same error he already reported.

      But probably he can do a binary search by only compiling the first half of the source.

      If it works add a quarter, otherwise subtract one.

      And so on, till he identified the problem...

      I think he will need to do the splitting manually tho, and can't rely on an automatic bisect.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      see Wikisyntax for the Monastery

        But probably he can do a binary search by only compiling the first half of the source.
        If it works add a quarter, otherwise subtract one.

        You can do this easily by inserting '__END__' after a subroutine, then moving it up or down a few subroutines based on whether perl -c reported any errors.

        90% of every Perl application is already written.
        dragonchild
Re^2: How do I find the missing curly brace??
by harangzsolt33 (Deacon) on Dec 31, 2024 at 00:36 UTC
    These are some really good ideas. Thank you! I like especially this one:

    "since nesting subs is rare in Perl I'd also grep for sub keywords which are (unusually) intended."