I have a example.c file with some codes and comment lines, In that file, I have a comment line for ex:
static Bool Start = FALSE;/* $n=Start$ $t=static Bool$ $i=FALSE$
$d=initialize start to false$ */
I am using perl to remove comment lines, i tried Regular Expressions to remove the comment lines.
I have tried the following code , but it is not working,
`open(F,"<","example.c") or die "Could not open the .c file ";
{
$MultilineComment0 = 0;
while(my $matchLine = <F>)
{
if (($matchLine =~ s/^.*\/\*.*/) && ($matchLine !~ m/\*\/$/)) # matches Code + Multi Comment line Ex: Variable Declaration statements
{
$MultilineComment0 = 1;
next; #removes comment part from excutable lines
}
if ($MultilineComment0 == 1)
{
if ($matchLine =~ m/\*\/$/)
{
$MultilineComment0 = 0;
}
next;
}
push(@executable_code_only, $matchLine);
}
}
close(F);
open(F, ">",example.c");
print F ("@executable_code_only");
close(F);`
I will be helpful if someone provide me a regular expression to remove these comment lines.