[perl]
sub commentFilter
{
my $fileName = shift ;#参数是文件中的字符串
my $mul_begin = 0 ;
open my $fd, " < $fileName" or die "error";
while( <$fd> )
{
if( m#\s/\*# )#if begin with: /*
{
$mul_begin = 1 ;
}
if($mul_begin)
{
if( m#\s\*/# ) #if end width */
{
$mul_begin = 0 ;
}
}
else
{
if( !m=^\s*(//|#)= ) # if begin with // or #
{
print $_ ;
}
}
}
}
[/perl]