37,741
社区成员
发帖
与我相关
我的任务
分享
if ( $filecontent =~ s{
/- #the start /*
.*? #the characters in the comment, - here must used non-greedy quantifiers ?
- / #the end */
\s* #the spaces between the comment and the next statement
}{}sx - ) #x ignore the comments and spaces in the pattern, s make . includes newline
{
print "\n-------------------------\n";
print $filecontent;
print "\n-------------------------\n";
}
my $filecontent;
# read the file content to $filecontent
if ( $filecontent =~ s{
/- #the start /*
.* #the characters in the comment
- / #the end */
\s* #the spaces between the comment and the next statement
}{}sx - ) #x ignore the comments and spaces in the pattern, s make . includes newline
{
print "\n-------------------------\n";
print $filecontent;
print "\n-------------------------\n";
}
#output $filecontent to the file