322e 发表于 2015-12-27 14:44:31

Perl:过滤注释

sub commentFilter{my $fileName = shift ;#参数是文件中的字符串my $mul_begin = 0 ;open my $fd, &quot; < $fileName&quot; or die &quot;error&quot;;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 $_ ;}}}}
页: [1]
查看完整版本: Perl:过滤注释