Perl:过滤注释
发布时间:2020-12-15 23:51:50 所属栏目:大数据 来源:网络整理
导读:[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 en
[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]
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |