- 论坛徽章:
- 0
|
5可用积分
如这样的文件:
CC -!- FUNCTION: Rapidly .
CC -!- CATALYTIC ACTIVITY: Acetylcholine.
CC -!- SUBUNIT: Homotetramer; composed .
CC Interacts with PRIMA1.
CC anchor it to the basal
CC (By similarity).
CC -!- SUBCELLULAR LOCATION: Cell junction, synapse. Secreted (By
CC similarity). Cell membrane; Peripheral membrane protein (By
CC similarity).
CC -!- SUBCELLULAR LOCATION: Isoform 2: Cell membrane;
CC anchor; Extracellular side (By similarity).
CC -!- ALTERNATIVE PRODUCTS:
CC Event=Alternative splicing; Named isoforms=2;
我要提取其中以SUBCELLULAR LOCATION开头的那一小段文件,如下:
SUBCELLULAR LOCATION: Cell junction, synapse. Secreted (By
similarity). Cell membrane; Peripheral membrane protein (By
similarity).
SUBCELLULAR LOCATION: Isoform 2: Cell membrane; Lipid-anchor, GPI-
anchor; Extracellular side (By similarity).
我现在写的
f($line=~ /SUBCELLULAR LOCATION:/)
{
print $line,"\n";
if ($array[$line_num]=~ /\-\!\-/)
{next;}
}
if( $array[$line_num] =~ /^\/\//)
{
$a++;
last;
只有其中的第一句话出来 不知道怎么办才好啊 谢谢各位了!!
[ 本帖最后由 flw 于 2008-6-20 13:16 编辑 ] |
最佳答案
查看完整内容
下面给出这一类问题的通用解决办法。这是面向行处理的一种轻量级解决方法。比那些对整个文件进行模式匹配的方法不知优雅了要多少倍。$start 表示开始标记的模式,$end 表示结束标记的模式,if ( (/$start/ .. /$end/) and !/$end/ ){表示需要开始和结束之间的,但不需要结束的那一行。运行结果:
|