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

Use perl to find perl errors.

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11163431 use warnings; my @what_lines; @ARGV = '3raindeermaze.pl'; # FIXME while( <> ) { for ( split // ) { /\{/ ? push @what_lines, $. : /\}/ ? pop @what_lines : 0; } } print "line numbers with unmatched { => @what_lines\n";

Comment out the ARGV line to use your file as the argument to the program.
( I just did that for testing. )

Replies are listed 'Best First'.
Re^2: How do I find the missing curly brace??
by LanX (Saint) on Dec 30, 2024 at 18:22 UTC
    consider this convoluted example (Perl would catch this anyway)
    sub bla { print "yadda"; my %hash = { foo => 1, ); }

    the problem is in line 3, but your code will report line 1.

    and if you add a # } after a comment in line 2 it won't report anything.

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