#!/usr/bin/perl use strict; use warnings; my( $code, @open ); while ( my $line = <> ) { $code .= $line; $code =~ s/'(?:\\.|[^'])*'|"(?:\\.|[^"])*"//g; # strip strings $code =~ s!/\*.*\*/!!g; # strip comments if ( $code !~ /["']|\/\*/ ) { # no open comment/string? $code =~ s!//.*!!; # strip eol-comments for ( split //, $code ) { push @open, $. if /\{/; if (/\}/) { warn "uncalled-for closing brace at line $.\n" unless @open; pop @open; } # if } # for $code = ''; } # if } # while warn @open ." open brace(s) not closed at line(s): ". join(", ", @open) ."\n" if @open;