使用Perl正则清空代码文件中所有以分号开头的注释 2015/12/14 15736 open(FILEHANDLE, "+<hello.asm") or die "can't open : $!\n"; @content= <FILEHANDLE>; seek FILEHANDLE, 0, 0; foreach (@content) { s/;.*//ig; print FILEHANDLE ; } truncate(FILEHANDLE,tell(FILEHANDLE)); close(FILEHANDLE);