fast search and replace in all files

Actually, I want to count the number of "{" and "}" in a C code file. If the number of "}" is more than "{" then a error message should be shown that the number of "}" increases than "{" at "LINE", line number should be shown here.

Please help its urgent.

Usage:

perl count.pl path/to/yourfile

count.pl

#!/usr/bin/perl
use strict;
use warnings;
my %count;
while(<>){
   $count{$1}++ while m/([{}])/g;
   if ($count{'}'} > $count{'{'}) {
      print STDOUT "Line# $. '}' = $count{'}'} , '{' = $count{'{'}\n";
      last;
   }
}

Finds first instance of } > { and stops. You did not specify if you wanted the script to continue after that.