Count uncommented, blank and source lines in perl

Hi friends, I am working on a perl script to count the commented lines, blank lines and source lines separately. Let me know if you have one. For example i have a file containing the lines:

 /**
 * SOURCE CODE
 */
 
public class SessionConstants {
  /**
   * Code for Session created
   */
public final static int CREATED_CODE = 0;
 
  /**
   * Constants defining the Session type
   */
  public enum SessionType {
    DC_SES, LC_SES, SM_SES
  }
}

The script should read the file and count the Commented lines(/* */), blank lines and actual source lines. The expected output should be, Commented lines=9, Blank lines=2, Source Lines=6. Thanks in advance.

Use this ,

#!/usr/bin/perl

use strict;
use warnings;

open FH,"<file";
my $space=0;
my $cmd=0;
my $ind=0;
my $code=0;
while(<FH>)
{

    if(/^$/)
    {
        $space++;
    }
    elsif(/\/\*.*\*\//)
    {
        $cmd++;
    }
    elsif(/\/\*/)
    {
        $cmd++;
        $ind=1;
    }
    elsif(/\*\//)
    {
        $cmd++;
        $ind=0;
    }
    elsif($ind==1)
    {
        $cmd++;
    }
    else
    {
        $code++;
    }
}

print " Commented Lines : $cmd\n";
print " Code Lines : $code \n";
print " Empty Lines : $space \n";

Thanks karthigayan for the effort, but the result is partially correct. Commented Lines : 9 is exactly correct. Code Lines : 8 is wrong, it must pick only 6 lines from the example i had given. Empty Lines : 0 but it must be 2. Please explain the flow if i am missing anything. Thanks again.

cloc counts blank lines, comment lines, and physical lines of source code: CLOC -- Count Lines of Code

My actual requirement was to execute a cleartool diff command on two files and the output of the diff command is shown below.

********************************
<<< file 1: M:\nm_int\SesCon.java@@\main\ga_jc\0
>>> file 2: M:\nm_int\SesCon.java@@\main\ga_jc\LATEST
********************************
--[after 0]--|------[inserted 1-97]-------
                 -| /**
                  |  *  SOURCE CODE
                  |  *  
                  |  */
                  | public class SessionConstants {
                  | 
                  |   /**
                  |    * Code for Session created
                  |    */
                  |   public final static int CREATED_CODE+
                  | 
                  |   /**
                  |    * Code for Session modified
                  |    */
                  |   public final static int MODIFIED_COD+
                  | 
                  |   /**
                  |    * Code for client log out
                  |    */
                  |   public final static int LOGOUT_CODE +
                  | 
                  | 
                  |   /**
                  |    * Constants defining the Session ty+
                  |    */
                  |   public enum SessionType {
                  |     DCFM_SESSION, LIC_SESSION, SMIA_SE+
                  |   }
                  | }
                  |-

This output must be used to count all the number of commented, blank and source lines. I tried the script given karthigayan but it doesnt work for blank aswell as source lines.

Thanks in advance.